System.Type.Equals(System.Type)

Here are the examples of the csharp api System.Type.Equals(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

813 Examples 7

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                HttpTriggerConfig p = (HttpTriggerConfig)obj;
                bool ret = AuthType == p.AuthType && Methods.Length == p.Methods.Length;

                for (int i = 0; i < Methods.Length; i = i + 1)
                {
                    ret = ret && (Methods[i] == p.Methods[i]);
                }
                return ret;
            }
        }

19 View Source File : ConversionSupport.cs
License : Apache License 2.0
Project Creator : apache

public static bool IsNMSType(object value)
        {
            bool result = false;
            int index = 0;
            Type t = NMSTypes[index];
            while (t != null && !result)
            {
                result = t.Equals(value.GetType());
                t = NMSTypes[++index];
            }
            return result;
        }

19 View Source File : Reflection.cs
License : MIT License
Project Creator : AlenToma

private Type GetChangeType(Type conversionType)
        {
            if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
                return Reflection.Instance.GetGenericArguments(conversionType)[0];

            return conversionType;
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                CdnEventsTriggerConfig p = (CdnEventsTriggerConfig)obj;
                bool ret = EventName == p.EventName && EventVersion == p.EventVersion && Notes == p.Notes && Filter.Count == p.Filter.Count;
                foreach(var item in Filter)
                {
                    ret = ret & p.Filter.ContainsKey(item.Key) && Enumerable.SequenceEqual(item.Value, p.Filter[item.Key]);
                }

                return ret;
            }
        }

19 View Source File : ServiceMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                LogConfig p = (LogConfig)obj;
                return (Project == p.Project) && (Logstore == p.Logstore);
            }
        }

19 View Source File : WinAPI.cs
License : Apache License 2.0
Project Creator : aequabit

public static IntPtr GetProcAddressEx(IntPtr hProc, IntPtr hModule, object lpProcName)
        {
            IntPtr zero = IntPtr.Zero;
            byte[] buffer = ReadRemoteMemory(hProc, hModule, 0x40);
            if ((buffer == null) || (BitConverter.ToUInt16(buffer, 0) != 0x5a4d))
            {
                return zero;
            }
            uint num = BitConverter.ToUInt32(buffer, 60);
            if (num <= 0)
            {
                return zero;
            }
            byte[] buffer2 = ReadRemoteMemory(hProc, hModule.Add((long) num), 0x108);
            if ((buffer2 == null) || (BitConverter.ToUInt32(buffer2, 0) != 0x4550))
            {
                return zero;
            }
            uint num2 = BitConverter.ToUInt32(buffer2, 120);
            uint num3 = BitConverter.ToUInt32(buffer2, 0x7c);
            if ((num2 <= 0) || (num3 <= 0))
            {
                return zero;
            }
            byte[] buffer3 = ReadRemoteMemory(hProc, hModule.Add((long) num2), 40);
            uint num4 = BitConverter.ToUInt32(buffer3, 0x1c);
            uint num5 = BitConverter.ToUInt32(buffer3, 0x24);
            uint num6 = BitConverter.ToUInt32(buffer3, 20);
            int num7 = -1;
            if ((num4 <= 0) || (num5 <= 0))
            {
                return zero;
            }
            if (lpProcName.GetType().Equals(typeof(string)))
            {
                int num8 = SearchExports(hProc, hModule, buffer3, (string) lpProcName);
                if (num8 > -1)
                {
                    byte[] buffer4 = ReadRemoteMemory(hProc, hModule.Add((long) (num5 + (num8 << 1))), 2);
                    num7 = (buffer4 == null) ? -1 : BitConverter.ToUInt16(buffer4, 0);
                }
            }
            else if (lpProcName.GetType().Equals(typeof(short)) || lpProcName.GetType().Equals(typeof(ushort)))
            {
                num7 = int.Parse(lpProcName.ToString());
            }
            if ((num7 <= -1) || (num7 >= num6))
            {
                return zero;
            }
            byte[] buffer5 = ReadRemoteMemory(hProc, hModule.Add((long) (num4 + (num7 << 2))), 4);
            if (buffer5 == null)
            {
                return zero;
            }
            uint num9 = BitConverter.ToUInt32(buffer5, 0);
            if ((num9 >= num2) && (num9 < (num2 + num3)))
            {
                string str = ReadRemoteString(hProc, hModule.Add((long) num9), null);
                if (!(string.IsNullOrEmpty(str) || !str.Contains(".")))
                {
                    zero = GetProcAddressEx(hProc, GetModuleHandleEx(hProc, str.Split(new char[] { '.' })[0]), str.Split(new char[] { '.' })[1]);
                }
                return zero;
            }
            return hModule.Add(((long) num9));
        }

19 View Source File : TypeCachingKey.cs
License : MIT License
Project Creator : aloneguid

public bool Equals(TypeCachingKey other)
      {
         if (ReferenceEquals(other, null)) return false;
         if (ReferenceEquals(other, this)) return true;

         return ClreplacedType.Equals(other.ClreplacedType) && Field.Equals(other.Field);
      }

19 View Source File : VssConnection.cs
License : MIT License
Project Creator : actions

public bool Equals(ClientCacheKey x, ClientCacheKey y)
                {
                    return x.Type.Equals(y.Type) &&
                           x.ServiceIdentifier.Equals(y.ServiceIdentifier);
                }

19 View Source File : AIBuildingBlocks.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools

private static IEnumerable<Type> ReflectDerivatives(Type forType, IEnumerable<Type> relevantTypes)
        {
            return from t in relevantTypes
                   where (t.IsSubclreplacedOf(forType) || forType.IsreplacedignableFrom(t) || t.Equals(forType))
                   select t;
        }

19 View Source File : VssJsonMediaTypeFormatter.cs
License : MIT License
Project Creator : actions

public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
        {
            // Do not wrap byte arrays as this is incorrect behavior (they are written as base64 encoded strings and
            // not as array objects like other types).

            Type typeToWrite = type;
            if (!m_bypreplacedSafeArrayWrapping
                && typeof(IEnumerable).GetTypeInfo().IsreplacedignableFrom(type.GetTypeInfo())
                && !type.Equals(typeof(Byte[]))
                && !type.Equals(typeof(JObject)))
            {
                typeToWrite = typeof(VssJsonCollectionWrapper);

                // IEnumerable will need to be materialized if they are currently not.
                object materializedValue = value is ICollection || value is string ?
                    value : // Use the regular input if it is already materialized or it is a string
                    ((IEnumerable)value)?.Cast<Object>().ToList() ?? value; // Otherwise, try materialize it

                value = new VssJsonCollectionWrapper((IEnumerable)materializedValue);
            }
            return base.WriteToStreamAsync(typeToWrite, value, writeStream, content, transportContext);
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                MnsTopicTriggerConfig p = (MnsTopicTriggerConfig)obj;
                return NotifyContentFormat == p.NotifyContentFormat && NotifyStrategy == p.NotifyStrategy && FilterTag == p.FilterTag;
            }
        }

19 View Source File : ServiceMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                MountPointsItem p = (MountPointsItem)obj;
                return (ServerAddr == p.ServerAddr) && (MountDir == p.MountDir);
            }
        }

19 View Source File : Agent.cs
License : MIT License
Project Creator : adrenak

public Action GetAction(Type action) {
            foreach (var a in mAvailableActions) 
                if (a.GetType().Equals(action))
                    return a;
            return null;
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                SouceConfig p = (SouceConfig)obj;
                return Logstore == p.Logstore;
            }
        }

19 View Source File : IdentityDescriptor.cs
License : MIT License
Project Creator : actions

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            return destinationType.Equals(typeof(string)) || base.CanConvertTo(context, destinationType);
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                OSSTriggerFilter p = (OSSTriggerFilter)obj;
                Console.WriteLine(Key.Equals(p.Key));
                return Key.Equals(p.Key);
            }
        }

19 View Source File : ChangeType.cs
License : MIT License
Project Creator : akasarto

public static T ChangeType<T>(this object @this, T defaultValue = default(T))
		{
			try
			{
				if (@this == null)
				{
					return defaultValue;
				}

				if (@this is T)
				{
					return (T)@this;
				}

				Type conversionType = typeof(T);

				// Nullables
				if (conversionType.IsGenericType && conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
				{
					conversionType = (new NullableConverter(conversionType)).UnderlyingType;
				}

				if (conversionType.IsEnum)
				{
					var enumStr = @this.ToString();

					// Clean the input string before attempting to convert.
					if (!string.IsNullOrWhiteSpace(enumStr))
					{
						enumStr = InvalidEnumValueChars.Replace(enumStr, string.Empty);
					}

					return (T)Enum.Parse(conversionType, enumStr, ignoreCase: true);
				}

				// String
				if (conversionType.Equals(typeof(string)))
				{
					return (T)((object)Convert.ToString(@this));
				}

				// Guid
				if (conversionType.Equals(typeof(Guid)))
				{
					var input = @this.ToString();

					if (string.IsNullOrWhiteSpace(input))
					{
						return defaultValue;
					}

					Guid output;
					if (Guid.TryParse(input, out output))
					{
						return (T)((object)output);
					}
				}

				// Bool
				if (conversionType.Equals(typeof(bool)))
				{
					return (T)((object)Convert.ToBoolean(@this));
				}

				// Datetime
				if (conversionType.Equals(typeof(DateTime)))
				{
					return (T)((object)DateTime.Parse(@this.ToString(), CultureInfo.CurrentCulture));
				}

				// TimeSpan
				if (conversionType.Equals(typeof(TimeSpan)))
				{
					return (T)((object)TimeSpan.Parse(@this.ToString(), CultureInfo.CurrentCulture));
				}

				// General
				return (T)Convert.ChangeType(@this, conversionType);
			}
			catch
			{
				return defaultValue;
			}
		}

19 View Source File : Enumeration.cs
License : MIT License
Project Creator : anjoy8

public override bool Equals(object obj)
        {
            var otherValue = obj as Enumeration;

            if (otherValue == null)
                return false;

            var typeMatches = GetType().Equals(obj.GetType());
            var valueMatches = Id.Equals(otherValue.Id);

            return typeMatches && valueMatches;
        }

19 View Source File : DictionaryCustomFormatter.cs
License : Apache License 2.0
Project Creator : A7ocin

public object GetFormat(Type formatType)
		{
			if (typeof(ICustomFormatter).Equals(formatType)) return this;
			return null;
		}

19 View Source File : PropertyUtil.cs
License : Apache License 2.0
Project Creator : apache

public static object ConvertType(Type targetType, string value)
        {
            if (targetType.IsPrimitive)
            {
                return Convert.ChangeType(value, targetType);
            }
            else if (targetType.Equals(typeof(string)))
            {
                return value;
            }
            return null;
        }

19 View Source File : LocalActionServicesLoader.cs
License : MIT License
Project Creator : alexandredenes

private string ConvertParam(Type parameterType)
        {
            if(parameterType.Equals(typeof(string)))
                return "string";
            return "number";
        }

19 View Source File : IPAddressConverter.cs
License : MIT License
Project Creator : alexandredenes

public override bool CanConvert(Type objectType)
        {
            return objectType.Equals(typeof(IPAddress));
        }

19 View Source File : BaseEventSystem.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private void TraverseEventSystemHandlerHierarchy<T>(IEventSystemHandler handler, Action<Type, IEventSystemHandler> func) where T : IEventSystemHandler
        {
            using (TraverseEventSystemHandlerHierarchyPerfMarker.Auto())
            {
                var handlerType = typeof(T);

                // Need to call on handlerType first, because GetInterfaces below will only return parent types.
                func(handlerType, handler);

                foreach (var iface in handlerType.GetInterfaces())
                {
                    if (!iface.Equals(eventSystemHandlerType))
                    {
                        func(iface, handler);
                    }
                }
            }
        }

19 View Source File : ServiceMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                VpcConfig p = (VpcConfig)obj;
                return (VpcId == p.VpcId) && (SecurityGroupId == p.SecurityGroupId) 
                    && Enumerable.SequenceEqual(VSwitchIds, p.VSwitchIds);
            }
        }

19 View Source File : ConnectionData.cs
License : MIT License
Project Creator : Adoxio

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			return (sourceType.Equals(typeof(Enum)));
		}

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                TimeTriggerConfig p = (TimeTriggerConfig)obj;
                return CronExpression == p.CronExpression && Payload == p.Payload && Enable == p.Enable;
            }
        }

19 View Source File : ServiceMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                NasConfig p = (NasConfig)obj;
                return (UserId == p.UserId) && (GroupId == p.GroupId) && 
                    (Enumerable.SequenceEqual(MountPoints, p.MountPoints));
            }
        }

19 View Source File : ConnectionData.cs
License : MIT License
Project Creator : Adoxio

public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
		{
			if (!destinationType.Equals(typeof(string)))
			{
				throw new ArgumentException(@"Can only convert to string.", "destinationType");
			}

			var name = value.ToString();

			var attrs = value.GetType().GetField(name).GetCustomAttributes(typeof(DescriptionAttribute), false);

			return (attrs.Length > 0) ? ((DescriptionAttribute)attrs[0]).Description : name;
		}

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                RdsTriggerConfig p = (RdsTriggerConfig)obj;
                return Enumerable.SequenceEqual(SubscriptionObjects, p.SubscriptionObjects) && Retry == p.Retry 
                            && Concurrency == p.Concurrency && EventFormat==p.EventFormat;
            }
        }

19 View Source File : IdentityDescriptor.cs
License : MIT License
Project Creator : actions

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            return sourceType.Equals(typeof(string)) || base.CanConvertFrom(context, sourceType);
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                JobConfig p = (JobConfig)obj;
                return MaxRetryTime == p.MaxRetryTime && TriggerInterval == p.TriggerInterval;
            }
        }

19 View Source File : SkinPreset.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public override bool Equals(object obj)
        {
            if (obj.GetType().Equals(GetType()))
            {
                return (obj as SkinPreset).Name.Equals(Name);
            }
            return false;
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                LogTriggerConfig p = (LogTriggerConfig)obj;
                return SourceConfig.Equals(p.SourceConfig) && JobConfig.Equals(p.JobConfig)
                        && (FunctionParameter.Count == p.FunctionParameter.Count && !FunctionParameter.Except(p.FunctionParameter).Any()) 
                        && LogConfig.Equals(p.LogConfig) && Enable == p.Enable;
            }
        }

19 View Source File : AObjectBase.cs
License : MIT License
Project Creator : 404Lcc

public void AutoReference(Transform transform, Dictionary<string, FieldInfo> fieldInfoDict)
        {
            string name = transform.name.ToLower();
            if (fieldInfoDict.ContainsKey(name))
            {
                if (fieldInfoDict[name].FieldType.Equals(typeof(GameObject)))
                {
                    fieldInfoDict[name].SetValue(this, transform.gameObject);
                }
                else if (fieldInfoDict[name].FieldType.Equals(typeof(Transform)))
                {
                    fieldInfoDict[name].SetValue(this, transform);
                }
                else
                {
                    fieldInfoDict[name].SetValue(this, transform.GetComponent(fieldInfoDict[name].FieldType));
                }
            }
            for (int i = 0; i < transform.childCount; i++)
            {
                AutoReference(transform.GetChild(i), fieldInfoDict);
            }
        }

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                OSSTriggerKey p = (OSSTriggerKey)obj;
                return Prefix == p.Prefix && Suffix == p.Suffix;
            }
        }

19 View Source File : ManualMap.cs
License : Apache License 2.0
Project Creator : aequabit

private static void PatchImports(JLibrary.PortableExecutable.PortableExecutable image, IntPtr hProcess, int processId)
        {
            string lpBuffer = string.Empty;
            string str2 = string.Empty;
            foreach (IMAGE_IMPORT_DESCRIPTOR image_import_descriptor in image.EnumImports())
            {
                if (image.ReadString((long) image.GetPtrFromRVA(image_import_descriptor.Name), SeekOrigin.Begin, out lpBuffer, -1, null))
                {
                    IMAGE_THUNK_DATA image_thunk_data;
                    IntPtr zero = IntPtr.Zero;
                    zero = GetRemoteModuleHandle(lpBuffer, processId);
                    if (zero.IsNull())
                    {
                        throw new FileNotFoundException(string.Format("Unable to load dependent module '{0}'.", lpBuffer));
                    }
                    uint ptrFromRVA = image.GetPtrFromRVA(image_import_descriptor.FirstThunkPtr);
                    uint num2 = (uint) Marshal.SizeOf(typeof(IMAGE_THUNK_DATA));
                    while (image.Read<IMAGE_THUNK_DATA>((long) ptrFromRVA, SeekOrigin.Begin, out image_thunk_data) && (image_thunk_data.u1.AddressOfData > 0))
                    {
                        IntPtr hModule = IntPtr.Zero;
                        object lpProcName = null;
                        if ((image_thunk_data.u1.Ordinal & 0x80000000) == 0)
                        {
                            if (!image.ReadString((long) (image.GetPtrFromRVA(image_thunk_data.u1.AddressOfData) + 2), SeekOrigin.Begin, out str2, -1, null))
                            {
                                throw image.GetLastError();
                            }
                            lpProcName = str2;
                        }
                        else
                        {
                            lpProcName = (ushort) (image_thunk_data.u1.Ordinal & 0xffff);
                        }
                        if (!(hModule = WinAPI.GetModuleHandleA(lpBuffer)).IsNull())
                        {
                            IntPtr ptr = lpProcName.GetType().Equals(typeof(string)) ? WinAPI.GetProcAddress(hModule, (string) lpProcName) : WinAPI.GetProcAddress(hModule, (uint) (((ushort) lpProcName) & 0xffff));
                            if (!ptr.IsNull())
                            {
                                hModule = zero.Add((long) ptr.Subtract(((long) hModule.ToInt32())).ToInt32());
                            }
                        }
                        else
                        {
                            hModule = WinAPI.GetProcAddressEx(hProcess, zero, lpProcName);
                        }
                        if (hModule.IsNull())
                        {
                            throw new EntryPointNotFoundException(string.Format("Unable to locate imported function '{0}' from module '{1}' in the remote process.", str2, lpBuffer));
                        }
                        image.Write<int>((long) ptrFromRVA, SeekOrigin.Begin, hModule.ToInt32());
                        ptrFromRVA += num2;
                    }
                }
            }
        }

19 View Source File : TransferScreen.cs
License : MIT License
Project Creator : allartprotocol

private async System.Threading.Tasks.Task PopulateInfoFileds(object data)
        {
            if (data != null && data.GetType().Equals(typeof(TokenAccount)))
            {
                this.transferTokenAccount = (TokenAccount)data;
                ownedAmmount_txt.text = $"{transferTokenAccount.Account.Data.Parsed.Info.TokenAmount.Amount}";
            }
            else
            {
                ownedSolAmmount = await SimpleWallet.instance.GetSolAmmount(SimpleWallet.instance.wallet.GetAccount(0));
                ownedAmmount_txt.text = $"{ownedSolAmmount}";
            }
        }

19 View Source File : IdentityDescriptor.cs
License : MIT License
Project Creator : actions

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType.Equals(typeof(string)))
            {
                IdenreplacedyDescriptor descriptor = value as IdenreplacedyDescriptor;

                return descriptor?.ToString() ?? string.Empty;
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }

19 View Source File : ValidationHandler.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : Altinn

public async Task ValidateData(object instance, ModelStateDictionary validationResults)
        {
            if (instance.GetType().Equals(typeof(SvarPaaNabovarselType)))
            {
                SvarPaaNabovarselType skjema = (SvarPaaNabovarselType)instance;
                if (skjema.nabo == null)
                {
                    validationResults.AddModelError("nabo.epost",  "Error: Epost required");
                }
            }

            await Task.CompletedTask;
        }

19 View Source File : ExposedParameter.cs
License : MIT License
Project Creator : alelievr

public override bool Equals(object obj)
        {
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
                return false;
            else
                return Equals((ExposedParameter)obj);
        }

19 View Source File : PropertyUtil.cs
License : Apache License 2.0
Project Creator : apache

protected override bool CanReflect(PropertyInfo reflectedProperty)
        {
            Type TargetType = reflectedProperty.PropertyType;
            return TargetType.IsPrimitive || TargetType.Equals(typeof(string));
        }

19 View Source File : XmlHelper.cs
License : MIT License
Project Creator : 279328316

public T DeserializeNode<T>(XmlNode node = null) where T : clreplaced, new()
        {
            T model = new T();
            XmlNode firstChild;
            if (node == null)
            {
                node = root;
            }
            firstChild = node.FirstChild;

            Dictionary<string, string> dict = new Dictionary<string, string>();

            XmlAttributeCollection xmlAttribute = node.Attributes;
            if (node.Attributes.Count > 0)
            {
                for (int i = 0; i < node.Attributes.Count; i++)
                {
                    if (!dict.Keys.Contains(node.Attributes[i].Name))
                    {
                        dict.Add(node.Attributes[i].Name, node.Attributes[i].Value);
                    }
                }
            }
            if (!dict.Keys.Contains(firstChild.Name))
            {
                dict.Add(firstChild.Name, firstChild.InnerText);
            }
            XmlNode next = firstChild.NextSibling;
            while (next != null)
            {
                if (!dict.Keys.Contains(next.Name))
                {
                    dict.Add(next.Name, next.InnerText);
                }
                else
                {
                    throw new Exception($"重复的属性Key:{next.Name}");
                }
                next = next.NextSibling;
            }


            #region 为对象赋值

            Type modelType = typeof(T);
            List<PropertyInfo> piList = modelType.GetProperties().Where(pro => (pro.PropertyType.Equals(typeof(string)) || pro.PropertyType.IsValueType) && pro.CanRead && pro.CanWrite).ToList();

            foreach (PropertyInfo pi in piList)
            {
                string dictKey = dict.Keys.FirstOrDefault(key => key.ToLower() == pi.Name.ToLower());
                if (!string.IsNullOrEmpty(dictKey))
                {
                    string value = dict[dictKey];
                    TypeConverter typeConverter = TypeDescriptor.GetConverter(pi.PropertyType);
                    if (typeConverter != null)
                    {
                        if (typeConverter.CanConvertFrom(typeof(string)))
                            pi.SetValue(model, typeConverter.ConvertFromString(value));
                        else
                        {
                            if (typeConverter.CanConvertTo(pi.PropertyType))
                                pi.SetValue(model, typeConverter.ConvertTo(value, pi.PropertyType));
                        }
                    }
                }
            }
            #endregion
            return model;
        }

19 View Source File : ExceptionSupport.cs
License : Apache License 2.0
Project Creator : apache

private static string[] GetStringConstants(Type type)
        {
            FieldInfo[] fields = GetConstants(type);
            ArrayList list = new ArrayList(fields.Length);
            foreach(FieldInfo fi in fields)
            {
                if (fi.FieldType.Equals(typeof(string)))
                {
                    list.Add(fi.GetValue(null));
                }
            }
            return (string[])list.ToArray(typeof(string));
        }

19 View Source File : JsonHelper.cs
License : MIT License
Project Creator : AlenToma

public static bool IsNullable(Type t)
        {
            if (!t.IsGenericType) return false;
            Type g = t.GetGenericTypeDefinition();
            return (g.Equals(typeof(Nullable<>)));
        }

19 View Source File : VssJsonMediaTypeFormatter.cs
License : MIT License
Project Creator : actions

public override MediaTypeFormatter GetPerRequestFormatterInstance(Type type, HttpRequestMessage request, MediaTypeHeaderValue mediaType)
        {
            if (GetType().Equals(typeof(VssJsonMediaTypeFormatter))) // ensures we don't return a VssJsonMediaTypeFormatter when this instance is not a VssJsonMediaTypeFormatter
            {
                return new VssJsonMediaTypeFormatter(request, m_bypreplacedSafeArrayWrapping);
            }
            else
            {
                return base.GetPerRequestFormatterInstance(type, request, mediaType); // basically returns this instance
            }
        }

19 View Source File : XmlHelper.cs
License : MIT License
Project Creator : 279328316

public static void SerializeCollection<T>(IEnumerable<T> list, string filePath) where T : clreplaced, new()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            Type modelType = typeof(T);
            XmlDeclaration declaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
            xmlDoc.AppendChild(declaration);
            XmlElement root = xmlDoc.CreateElement(string.Format("{0}List", modelType.Name));
            xmlDoc.AppendChild(root);

            List<PropertyInfo> piList = modelType.GetProperties().Where(pro => (pro.PropertyType.Equals(typeof(string)) || pro.PropertyType.IsValueType) && pro.CanRead && pro.CanWrite).ToList();
            foreach (T item in list)
            {
                XmlNode xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, modelType.Name, "");
                root.AppendChild(xmlNode);

                foreach (PropertyInfo pi in piList)
                {
                    object value = pi.GetValue(item);
                    if (value != null)
                    {
                        var propertyNode = xmlDoc.CreateNode(XmlNodeType.Element, pi.Name, "");
                        propertyNode.InnerText = value.ToString();
                        xmlNode.AppendChild(propertyNode);
                    }
                }
            }
            xmlDoc.Save(filePath);
        }

19 View Source File : XmlHelper.cs
License : MIT License
Project Creator : 279328316

public static void Serialize<T>(T dto, string xmlPathName) where T : clreplaced, new()
        {
            XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
            Type modelType = typeof(T);
            XmlDeclaration declaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
            xmlDoc.AppendChild(declaration);
            XmlElement root = xmlDoc.CreateElement(modelType.Name);
            xmlDoc.AppendChild(root);

            List<PropertyInfo> piList = modelType.GetProperties().Where(pro => (pro.PropertyType.Equals(typeof(string)) || pro.PropertyType.IsValueType) && pro.CanRead && pro.CanWrite).ToList();

            foreach (PropertyInfo pi in piList)
            {
                object value = pi.GetValue(dto);
                if (value != null)
                {
                    var propertyNode = xmlDoc.CreateNode(XmlNodeType.Element, pi.Name, "");
                    propertyNode.InnerText = value.ToString();
                    root.AppendChild(propertyNode);
                }
            }
            xmlDoc.Save(xmlPathName);
        }

19 View Source File : ExpressionValue.cs
License : MIT License
Project Creator : actions

public override Boolean CanConvert(Type objectType)
        {
            return objectType.GetTypeInfo().Equals(typeof(String).GetTypeInfo()) || typeof(T).GetTypeInfo().IsreplacedignableFrom(objectType.GetTypeInfo());
        }

19 View Source File : ConnectionData.cs
License : MIT License
Project Creator : Adoxio

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			return (destinationType.Equals(typeof(string)));
		}

19 View Source File : TriggerConfigMeta.cs
License : MIT License
Project Creator : aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                OSSTriggerConfig p = (OSSTriggerConfig)obj;
                return Filter.Equals(p.Filter) && Enumerable.SequenceEqual(Events, p.Events);
            }
        }

See More Examples