T GetTemplate <T>(string style = null) where T : Component { System.Type typeParameterType = typeof(T); // return default(T); if (typeParameterType.Equals(typeof(Button))) { return(buttonPrefab as T); } if (typeParameterType.Equals(typeof(Toggle))) { return(togglePrefab as T); } if (typeParameterType.Equals(typeof(Slider))) { return(sliderPrefab as T); } if (typeParameterType.Equals(typeof(Text))) { if (style != null) { if (style.Contains("header")) { return(headerPrefab.GetComponentInChildren <Text>() as T); } } return(smallLabel.GetComponentInChildren <Text>() as T); } if (typeParameterType.Equals(typeof(RectTransform))) { return(panel as T); } Debug.Log("no match"); return(default(T)); }
public MonthType(string name, System.Type type, Net.Vpc.Upa.Types.Month min, Net.Vpc.Upa.Types.Month max, bool nullable) : base(name, type == null ? typeof(Net.Vpc.Upa.Types.Month) : type, 0, 0, nullable) { if (type != null && !type.Equals(typeof(Net.Vpc.Upa.Types.Month)) && !type.Equals(typeof(Net.Vpc.Upa.Types.Temporal))) { throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Invalid Temporal Type " + type); } this.min = min; this.max = max; SetDefaultNonNullValue(Convert(new Net.Vpc.Upa.Types.DateTime(0))); }
public static System.Type BestFit(System.Type cls1, System.Type cls2) { cls1 = ValidateType(cls1); cls2 = ValidateType(cls2); if (cls1.Equals(cls2)) { return cls1; } if (cls1.Equals(typeof(byte?))) { return cls2; } else if (cls1.Equals(typeof(short?))) { if (cls2.Equals(typeof(byte?))) { return cls2; } else { return cls2; } } else if (cls1.Equals(typeof(int?))) { if (cls2.Equals(typeof(byte?)) || cls2.Equals(typeof(short?))) { return cls1; } else { return cls2; } } else if (cls1.Equals(typeof(long?))) { if (cls2.Equals(typeof(byte?)) || cls2.Equals(typeof(short?)) || cls2.Equals(typeof(int?))) { return cls1; } else if (cls2.Equals(typeof(short?))) { return typeof(double?); } else { return cls2; } } else if (cls1.Equals(typeof(float?))) { if (cls2.Equals(typeof(byte?)) || cls2.Equals(typeof(short?)) || cls2.Equals(typeof(int?))) { return cls1; } else if (cls2.Equals(typeof(long?))) { return typeof(double?); } else if (cls2.Equals(typeof(System.Numerics.BigInteger?))) { return typeof(System.Decimal?); } else { return cls2; } } else if (cls1.Equals(typeof(double?))) { if (cls2.Equals(typeof(byte?)) || cls2.Equals(typeof(short?)) || cls2.Equals(typeof(int?)) || cls2.Equals(typeof(long?)) || cls2.Equals(typeof(float?))) { return cls1; } else if (cls2.Equals(typeof(System.Numerics.BigInteger?))) { return typeof(System.Decimal?); } else { return cls2; } } else if (cls1.Equals(typeof(System.Numerics.BigInteger?))) { if (cls2.Equals(typeof(byte?)) || cls2.Equals(typeof(short?)) || cls2.Equals(typeof(int?)) || cls2.Equals(typeof(long?))) { return typeof(System.Decimal?); } else { return cls2; } } else if (cls1.Equals(typeof(System.Decimal?))) { return cls1; } else { throw new System.ArgumentException ("Unsupported"); } }
/// <summary> /// 整数型かどうか? /// System.Numeric.BigIntegerも含みます /// <seealso cref="Hinode.Tests.CSharp.Extensions.IsIntegerPasses()"/> /// </summary> /// <param name="t"></param> /// <returns></returns> public static bool IsInteger(this System.Type t) => t.Equals(typeof(sbyte)) || t.Equals(typeof(short)) || t.Equals(typeof(int)) || t.Equals(typeof(long)) || t.Equals(typeof(byte)) || t.Equals(typeof(ushort)) || t.Equals(typeof(uint)) || t.Equals(typeof(ulong)) || t.Equals(typeof(BigInteger));
protected internal virtual bool IsDetailOrMasterEntity(Net.Vpc.Upa.Entity e) { string n = e.GetName(); System.Type t = e.GetEntityType(); if (n.Equals(relationDescriptor.GetSourceEntity()) || t.Equals(relationDescriptor.GetSourceEntityType())) { return(true); } if (n.Equals(relationDescriptor.GetTargetEntity()) || t.Equals(relationDescriptor.GetTargetEntityType())) { return(true); } return(false); }
public void RemoveComponents(params System.Type[] componentTypes) { Components.Lock(); foreach (Component c in Components) { bool canRemove = false; System.Type type = c.GetType(); foreach (System.Type componentType in componentTypes) { if (type.Equals(componentType)) { canRemove = true; break; } } if (canRemove && Components.Remove(c)) { ComponentRemoved(c); c.Enabled = false; c.OnSceneRemoved(wipe: true); c.OnRemoved(); } } Components.Unlock(); }
public virtual void MergeHierarchy(Net.Vpc.Upa.Config.Decoration gid) { if (gid.GetConfig().GetOrder() >= hierarchyConfigOrder) { specified = true; hierarchy = true; manyToOne = true; targetEntity = baseFieldInfo.GetEntityInfo().GetName(); System.Type entityType = baseFieldInfo.GetEntityInfo().GetEntityType(); targetEntityType = entityType; if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsUndefinedValue <Net.Vpc.Upa.RelationshipType>(typeof(Net.Vpc.Upa.RelationshipType), relationType)) { relationType = Net.Vpc.Upa.RelationshipType.COMPOSITION; } System.Type nativeClass = GetFieldType(); if (!nativeClass.Equals(entityType)) { throw new System.ArgumentException("Hierarchy Relationship invalid as " + nativeClass + " <> " + entityType); } if ((gid.GetString("path")).Length > 0) { hierarchyPathField = gid.GetString("path"); } if ((gid.GetString("separator")).Length > 0) { hierarchyPathSeparator = gid.GetString("separator"); } if (gid.GetConfig().GetOrder() > hierarchyConfigOrder) { hierarchyConfigOrder = gid.GetConfig().GetOrder(); } } }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || GetType() != o.GetType()) { return(false); } Net.Vpc.Upa.Impl.Config.Callback.PosInvokeArgument that = (Net.Vpc.Upa.Impl.Config.Callback.PosInvokeArgument)o; if (pos != that.pos) { return(false); } if (acceptSubClasses != that.acceptSubClasses) { return(false); } if (name != null ? !name.Equals(that.name) : that.name != null) { return(false); } return(!(platformType != null ? !platformType.Equals(that.platformType) : that.platformType != null)); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { var other = obj as HierarchyMessage; if (other == null) { return(false); } if (!messageID.Equals(other.messageID)) { return(false); } if (!baseID.Equals(other.baseID)) { return(false); } if (!primitiveType.Equals(other.primitiveType)) { return(false); } if (!type.Equals(other.type)) { return(false); } if (!manifestModule.Equals(other.manifestModule)) { return(false); } return(true); }
private static void writeFields(string name, object obj, System.Type c, Dictionary <Ice.Object, object> objectTable, OutputBase output) { if (!c.Equals(typeof(object))) { // // Write the superclass first. // writeFields(name, obj, c.BaseType, objectTable, output); // // Write the declared fields of the given class. // FieldInfo[] fields = c.GetFields(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); for (int i = 0; i < fields.Length; i++) { string fieldName = (name != null ? name + '.' + fields[i].Name : fields[i].Name); try { object val = fields[i].GetValue(obj); writeValue(fieldName, val, objectTable, output); } catch (System.UnauthorizedAccessException) { Debug.Assert(false); } } } }
public static bool IsSimple(System.Type type) { if (type == null) { return(false); //Not sure why it is null but it do be like that sometime. } return(type.IsPrimitive || type.Equals(typeof(string))); }
protected override HbmMapping GetMappings() { var mapper = new ConventionModelMapper(); System.Type baseEntityType = typeof(DomainObject); mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && !baseEntityType.Equals(t)); mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType)); mapper.Class <DomainObject>(r => { r.Version(x => x.EntityVersion, map => { }); r.Id(x => x.ID, map => map.Generator(Generators.Native)); }); mapper.Class <Class1>(r => { r.IdBag(x => x.Class2List, map => map.Inverse(true), rel => rel.ManyToMany()); }); mapper.Class <Class2>(r => { r.IdBag <Class1>("_class1List", map => { }, rel => rel.ManyToMany()); }); HbmMapping mappings = mapper.CompileMappingFor(new[] { typeof(Class1), typeof(Class2) }); return(mappings); }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledPlus)oo; System.Type t1 = o.GetLeft().GetTypeTransform().GetTargetType().GetPlatformType(); System.Type t2 = o.GetRight().GetTypeTransform().GetTargetType().GetPlatformType(); bool s0 = o.GetTypeTransform().GetTargetType().GetPlatformType().Equals(typeof(string)); bool s1 = t1.Equals(typeof(string)); bool s2 = t2.Equals(typeof(string)); if (s0 || s1 || s2) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c1 = o.GetLeft().Copy(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression c2 = o.GetRight().Copy(); c1.SetParentExpression(null); c2.SetParentExpression(null); if (!s1) { if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t1)) { c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy()); } else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t1)) { c1 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c1.Copy()); } else { throw new System.ArgumentException("Unsupported"); } } if (!s2) { if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyInteger(t2)) { c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy()); } else if (Net.Vpc.Upa.Impl.Util.PlatformUtils.IsAnyFloat(t2)) { c2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(c2.Copy()); } else { throw new System.ArgumentException("Unsupported"); } } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat cc = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat(c1, c2); return(sqlManager.GetSQL(cc, qlContext, declarations)); } string leftValue = o.GetLeft() != null?sqlManager.GetSQL(o.GetLeft(), qlContext, declarations) : "NULL"; string rightValue = o.GetRight() != null?sqlManager.GetSQL(o.GetRight(), qlContext, declarations) : "NULL"; string s = null; s = leftValue + " + " + rightValue; return("(" + s + ")"); }
public static object ValueOf(string s, System.Type c) { if (c == (typeof(string))) { return(s); } if (c == (typeof(int?))) { return(System.Convert.ToInt32(s)); } if (c == typeof(float?)) { return(System.Convert.ToSingle(s)); } if (c == (typeof(long?))) { return(System.Convert.ToInt64(s)); } if (c == typeof(short?)) { return(System.Convert.ToInt16(s)); } if (c == typeof(byte?)) { return(System.Convert.ToByte(s)); } if (c.Equals(typeof(System.Numerics.BigInteger?))) { return(Net.Vpc.Upa.Impl.FwkConvertUtils.CreateBigInteger(s)); } if (c.Equals(typeof(Net.Vpc.Upa.Types.Time))) { return(Net.Vpc.Upa.Impl.Util.DateUtils.ParseUniversalTime(s)); } if (c.Equals(typeof(Net.Vpc.Upa.Types.Date))) { return(Net.Vpc.Upa.Impl.Util.DateUtils.ParseUniversalDate(s)); } if (c.Equals(typeof(Net.Vpc.Upa.Types.Temporal))) { return(Net.Vpc.Upa.Impl.Util.DateUtils.ParseUniversalDateTime(s)); } return(null); }
public override bool Equals(object obj) { if (obj is QueryKey) { QueryKey key = (QueryKey)obj; return(queryName.Equals(key.queryName) && queryReturnType.Equals(key.queryReturnType)); } return(false); }
public void LoadAsset() { switch (LoadState) { case AssetLoadState.NotLoad: LoadState = AssetLoadState.Loading; string abName = ABManifest.GetAssetBundleByAssetPath(assetPath); var assetBundle = AssetBundle.LoadFromFile(abName); if (loadType.Equals(typeAB) == false) { asset = assetBundle.LoadAsset(ABManifest.GetAssetNameByAssetPath(this.assetPath), loadType); } var directDependencies = ABManifest.AssetBundleManifest.GetDirectDependencies(System.IO.Path.GetFileName(abName)); totalDirectDependecntCount = directDependencies.Length; foreach (var directDependent in directDependencies) { assetLoader.LoadAssetBundle(directDependent); } LoadState = AssetLoadState.Loaded; break; case AssetLoadState.Loading: Debug.LogError("资源已在异步加载队列中,无法立即加载。AssetPath:" + this.assetPath); break; case AssetLoadState.Loaded: break; case AssetLoadState.Unload: Debug.LogError("资源已卸载,任在加载。"); break; case AssetLoadState.LoadError: break; } }
public override void InspectorGui() { System.Type type = System.Type.GetType(this.type); if (type.Equals(typeof(int))) { @int = EditorGUILayout.IntField("Int:", @int); } else if (type.Equals(typeof(float))) { @float = EditorGUILayout.FloatField("Float:", @float); } else if (type.Equals(typeof(Vector3))) { vector3 = EditorGUILayout.Vector3Field("Vector3:", vector3); } else if (type.IsSubclassOf(typeof(Object))) { @object = EditorGUILayout.ObjectField("Object:", @object, type, true); } }
public static bool IsComplex(System.Type typeIn) { if (typeIn.IsSubclassOf(typeof(System.ValueType)) || typeIn.Equals(typeof(string))) //|| typeIn.IsPrimitive { return(false); } else { return(true); } }
/// <summary> /// 投げることになる問題の型を受け取るコンストラクター /// </summary> /// <param name="exceptionType"></param> public DeclaredExceptionAttribute(System.Type exceptionType) { // "問題" を例外に限るのか、それともそれ以外の類の問題も含めるのかは要検討だが // 一旦は例外に限って検討を進める。 if (!((exceptionType.Equals(typeof(Exception))) || (exceptionType.IsSubclassOf(typeof(Exception))))) { // 指定された型が例外ではない場合。 throw new Exception("Argument exceptionType must be a Exception."); } this._exceptionType = exceptionType; }
public override void InspectorGui() { size = EditorGUILayout.DelayedIntField("Size:", size); System.Type type = System.Type.GetType(this.type); if (type.Equals(typeof(int))) { ListInt(); } else if (type.Equals(typeof(float))) { ListFloat(); } else if (type.Equals(typeof(Vector3))) { ListVector3(); } else if (type.IsSubclassOf(typeof(Object))) { ListObject(type); } }
public object Deserialize(TextReader stream, System.Type type) { var keyTypeGetter = GetKeyTypeGetter(type); var(info, context) = CreateInfoAndContext(type); ReadTo(stream, info, keyTypeGetter); object inst = _instanceCreator?.Desirialize(type, info, context); if (inst != null) { return(inst); } else if (type.Equals(DEFAULT_TYPE)) { var dict = new Dictionary <string, object>(); foreach (var v in info.GetEnumerable()) { dict.Add(v.Name, v.Value); } } else if (type.ContainsInterface <ISerializable>()) { var ctor = type.GetConstructor(new[] { typeof(SerializationInfo), typeof(StreamingContext) }); Assert.IsNotNull(ctor, $"Not Define Constractor(SerializationInfo, StreamingContext)... type={type}"); inst = ctor.Invoke(new object[] { info, context }); } else if (type.GetCustomAttribute <System.SerializableAttribute>() != null || type.IsStruct()) { //空引数のコンストラクを持つものだけ対応している var ctor = type.GetConstructor(new System.Type[] { }); //var ctor = type.GetConstructor(null); Assert.IsNotNull(ctor, $"Not Define Default Constractor()... type={type}"); Assert.AreEqual(0, ctor.GetParameters().Length, $"Not Define Default Constractor()... type={type} argsCount={ctor.GetParameters().Length}"); inst = ctor.Invoke(new object[] { }); foreach (var fieldInfo in inst.GetSerializedFieldEnumerable() .Where(_i => info.GetEnumerable().Any(_e => _e.Name == _i.FieldInfo.Name))) { //Debug.Log($"debug -- Desirialize -- {fieldInfo.FieldInfo.Name} type={fieldInfo.FieldInfo.FieldType}"); var value = info.GetValue(fieldInfo.FieldInfo.Name, fieldInfo.FieldInfo.FieldType); fieldInfo.FieldInfo.SetValue(inst, value); } } else { Debug.LogWarning($"This type({type.FullName}) don't deserialize..."); } return(inst); }
private void OnSelectionChange() { if (Selection.activeObject == null) { return; } System.Type activeType = Selection.activeObject.GetType(); selectedClip = null; selectedSound = null; selectedMusic = null; if (activeType.Equals(typeof(AudioClip))) { selectedClip = (AudioClip)Selection.activeObject; CreateAudioHelper(selectedClip); } else if (activeType.Equals(typeof(AudioFileSoundObject))) { selectedSound = ((AudioFileSoundObject)Selection.activeObject); selectedClip = selectedSound.file; CreateAudioHelper(selectedClip); } else if (activeType.Equals(typeof(AudioFileMusicObject))) { selectedMusic = ((AudioFileMusicObject)Selection.activeObject); selectedClip = selectedMusic.file; CreateAudioHelper(selectedClip, true); } else { DoForceRepaint(true); return; } helperSource.clip = selectedClip; DoForceRepaint(true); }
//Make sure to use wrapper ability namespace, //otherwise the method won't find the ability Opsive.ThirdPersonController.Abilities.Ability FindAbility(System.Type _type) { if (AllCompsAreValid) { foreach (var _ability in myController.Abilities) { if (_type.Equals(_ability.GetType())) { return(_ability); } } } return(null); }
internal static void ValidClass(System.Type c, Net.Vpc.Upa.Impl.Config.Annotationparser.OverriddenValue <System.Type> oldVal, System.Type type, int processOrder) { if (c != null && !c.Equals(typeof(void))) { if (type.IsAssignableFrom(c)) { oldVal.SetBetterValue(c, processOrder); } else { throw new System.ArgumentException("Expected type " + type); } } }
internal static System.Type ValidClass(System.Type c, System.Type oldVal, System.Type type) { if (c != null && !c.Equals(typeof(void))) { if (type.IsAssignableFrom(c)) { return(c); } else { throw new System.ArgumentException("Expected type " + type); } } return(oldVal); }
public Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledConcat Add(Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression expression) { if (expression == this) { throw new System.Exception("WOOOOOOOODOOOOOOO"); } else { if (expression.GetTypeTransform() != null) { System.Type platformType = expression.GetTypeTransform().GetTargetType().GetPlatformType(); if (platformType.Equals(typeof(int?)) || platformType.Equals(typeof(int)) || platformType.Equals(typeof(System.Numerics.BigInteger?))) { expression = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledI2V(expression); } else if (platformType.Equals(typeof(double?)) || platformType.Equals(typeof(double)) || platformType.Equals(typeof(System.Decimal?))) { expression = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledD2V(expression); } } ProtectedAddArgument(expression); return(this); } }
public IEnumerable <MemberInfo> GetSubEntityMembers(System.Type entityClass, System.Type entitySuperclass) { const BindingFlags flattenHierarchyBindingFlag = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy; if (!entitySuperclass.Equals(entityClass.BaseType)) { IEnumerable <MemberInfo> propertiesOfSubclass = GetCandidatePersistentProperties(entityClass, flattenHierarchyBindingFlag); IEnumerable <MemberInfo> propertiesOfBaseClass = GetCandidatePersistentProperties(entitySuperclass, flattenHierarchyBindingFlag); return(propertiesOfSubclass.Except(propertiesOfBaseClass, new PropertyNameEqualityComparer()).Concat(GetUserDeclaredFields(entityClass).Cast <MemberInfo>())); } else { return(GetCandidatePersistentProperties(entityClass, SubClassPropertiesBindingFlags).Concat(GetUserDeclaredFields(entityClass).Cast <MemberInfo>())); } }
public bool Filter(Object obj, bool isMain) { if (obj == null || obj.Equals(null)) { return(isMain); } string path = AssetDatabase.GetAssetPath(obj); if (string.IsNullOrEmpty(path)) { path = obj.name; } if (isMain) { if (mFilterTypes.Count > 0) { System.Type type = obj.GetType(); bool flag = false; for (int i = mFilterTypes.Count - 1; i >= 0; i--) { if (type.Equals(mFilterTypes[i]) || type.IsSubclassOf(mFilterTypes[i])) { flag = true; break; } } if (!flag) { return(false); } } return(FilterContent(path, mKeyWords[(int)eTypes.Default], true)); } eTypes et = GetObjectType(obj); if (et == eTypes.Default) { return(true); } List <string> filters = mKeyWords[(int)et]; return(FilterContent(path, filters, false)); }
public static bool Equals(object o1, object o2) { if (o1 == o2) { return(true); } if (o1 == null || o2 == null) { return(false); } if (!(o1.GetType()).IsArray) { return(o1.Equals(o2)); } System.Type clz = o1.GetType().GetElementType(); if ((clz).IsPrimitive) { System.Type clz2 = o2.GetType().GetElementType(); if (clz.Equals(clz2)) { Net.Vpc.Upa.Impl.Util.Eq.EqualHelper h = Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <System.Type, Net.Vpc.Upa.Impl.Util.Eq.EqualHelper>(equalsHelpers, clz); if (h != null) { return(h.Equals(o1, o2)); } } throw new System.ArgumentException("could not compare primitive arrays"); } //return false; object[] o1arr = (object[])o1; object[] o2arr = (object[])o2; if (o1arr.Length != o2arr.Length) { return(false); } else { System.Collections.Generic.ICollection <object> o1coll = new System.Collections.Generic.List <object>(o1arr); System.Collections.Generic.ICollection <object> o2coll = new System.Collections.Generic.List <object>(o2arr); return(o1coll.Equals(o2coll)); } }
public override string ToString() { System.Type javaClass = targetType.GetPlatformType(); int length = targetType.GetScale(); int precision = targetType.GetPrecision(); string tname = Net.Vpc.Upa.Types.TypesFactory.GetTypeName(javaClass); if (tname == null) { tname = ("UNKNOWN_TYPE(" + (javaClass).FullName + "," + length + "," + precision + ")"); } if (javaClass.Equals(typeof(string))) { if (length > 0) { tname = tname + "(" + length + ")"; } } return("cast(" + @value + "," + tname + ")"); }