/// <summary> /// Transforms an IVertex in a property definition. /// </summary> /// <param name="myVertex">A vertex that represents a property definition.</param> /// <returns>A property definition.</returns> public IPropertyDefinition CreatePropertyDefinition(IVertex myVertex, IBaseType myDefiningType = null) { var attributeID = GetUUID(myVertex); var baseType = GetBaseType(myVertex); var isMandatory = GetIsMandatory(myVertex); var multiplicity = GetPropertyMultiplicity(myVertex); var name = GetAttributeDotName(myVertex); var defaultValue = GetDefaultValue(myVertex, baseType); var definingType = myDefiningType ?? GetDefiningType(myVertex); var inIndices = GetInIndices(myVertex); var isUserDefined = GetAttributeDotIsUserDefined(myVertex); return(new PropertyDefinition { BaseType = baseType, IsMandatory = isMandatory, Multiplicity = multiplicity, Name = name, RelatedType = definingType, DefaultValue = defaultValue, InIndices = inIndices, ID = myVertex.VertexID, IsUserDefined = isUserDefined, }); }
virtual public void ClearScriptObject() { if (mIsDestory) { return; } mIsDestory = true; CallFunctionVoid("OnDestroy"); if (mOnGUIDelegate != null) { mOnGUIDelegate.Dispose(); mOnGUIDelegate = null; } if (mLateUpdateDelegate != null) { mLateUpdateDelegate.Dispose(); mLateUpdateDelegate = null; } if (mFixedUpdateDelegate != null) { mFixedUpdateDelegate.Dispose(); mFixedUpdateDelegate = null; } if (mUpdateDelegate != null) { mUpdateDelegate.Dispose(); mUpdateDelegate = null; } mObject = null; mScriptType = null; mCodeTool = null; }
public ServiceBaseType(IBaseType myBaseType) { this.ID = myBaseType.ID; this.Comment = myBaseType.Comment; this.Name = myBaseType.Name; this.IsUserDefined = myBaseType.IsUserDefined; }
override public K GetCSLEDelegate <K>(string _Function, IBaseType _classtype, object _target) { if (_classtype == null || _target == null) { return(default(K)); } object ret = null; Method_CS methodctor = (Method_CS)GetLMethod(_classtype, _target, _Function, 0); if (methodctor == null) { return(default(K)); } try { ret = Delegate.CreateDelegate(typeof(K), _target, methodctor.SMethod); return((K)ret); } catch (Exception _error) { DLog.LogErrorFormat("_classtype = {0},_Function = {1},error = {2}", _classtype.Name, _Function, _error); return(default(K)); } }
override public object GetObject(IBaseType _type, params object[] _parmas) { if (_type == null) { throw new NullReferenceException("SYS GetCSLEObjectParmasByType _type = null"); } return(Activator.CreateInstance(_type.TypeForCLR, _parmas)); }
public void DoSomething(IBaseType <BGenericType> parameter) { IBaseType <AGenericType> w1 = new BaseWhatever(); w1.Field = parameter.Field; // automapper DoSomething(w1); }
public def_BaseTypes(IBaseType c) : this() { if (c != null) { baseTypeId = c.baseTypeId; enumeration = c.enumeration; } }
public bool IsDescendant(IBaseType myOtherType) { for (var current = RetrieveParentType(); current != null; current = current.RetrieveParentType()) { if (current.Equals(myOtherType)) return true; } return false; }
override public object GetTargetMemberByIndex(int _index, object _target) { if (_target == null) { return(null); } IBaseType ttype = GetObjectType(_target); return(GetMemberByIndex(ttype, _index, _target)); }
override public object GetTargetMemberByKey(string _key, object _target) { if (_target == null) { return(null); } IBaseType ttype = GetObjectType(_target); return(GetMemberByKey(ttype, _key, _target)); }
static void Main(string[] args) { var baseObject = new BaseClass(); IBaseType someObject = baseObject; someObject.FancyMethod(); // Dekorujemy obiekt, przez co przy używaniu funkcji dodajemy nowe instrukcje someObject = new AnotherDecorator(new Decorator(baseObject)); someObject.FancyMethod(); }
private void CheckInjectableProperties(IBaseType baseObj) { var props = baseObj.ImplType.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance); foreach (var p in props) { if (p.IsDefined(typeof(Injectable), true)) { baseObj.InjectableProperties.Add(p); } } }
public static ServiceBaseType ToServiceBaseType(IBaseType myBaseType) { ServiceBaseType svcBaseType = null; if (myBaseType is IVertexType) { svcBaseType = new ServiceVertexType((IVertexType)myBaseType); } else if (myBaseType is IEdgeType) { svcBaseType = new ServiceEdgeType((IEdgeType)myBaseType); } return svcBaseType; }
public static ServiceBaseType ToServiceBaseType(IBaseType myBaseType) { ServiceBaseType svcBaseType = null; if (myBaseType is IVertexType) { svcBaseType = new ServiceVertexType((IVertexType)myBaseType); } else if (myBaseType is IEdgeType) { svcBaseType = new ServiceEdgeType((IEdgeType)myBaseType); } return(svcBaseType); }
internal static IBaseType ToBaseType(ServiceBaseType myBaseType, IServiceToken myServiceToken) { IBaseType result = null; if (myBaseType is ServiceVertexType) { result = new RemoteVertexType((ServiceVertexType)myBaseType, myServiceToken); } else if (myBaseType is ServiceEdgeType) { result = new RemoteEdgeType((ServiceEdgeType)myBaseType, myServiceToken); } return(result); }
override public void SetMember(IBaseType _type, string _key, object _object, object _target) { if (_type == null) { return; } FieldInfo pi = _type.TypeForCLR.GetField(_key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (pi == null) { throw new NullReferenceException("SYS SetMember pi = null ,_key = " + _key); } pi.SetValue(_target, _object); }
override public object GetMemberByKey(IBaseType _type, string _key, object _object) { if (_type == null) { throw new NullReferenceException("Base GetMember _type = null"); } FieldInfo pi = _type.TypeForCLR.GetField(_key, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (pi == null) { throw new NullReferenceException("Base GetMember FieldInfo pi = null"); } return(pi.GetValue(_object)); }
private void CheckSingleEdge(EdgePredefinition edge, IBaseType myTargetType) { if (edge.ContainedEdges != null) { //TODO better exception here. throw new Exception("A single edge can not contain other edges."); } if (edge.VertexIDsByVertexTypeID == null && edge.VertexIDsByVertexTypeName == null) { //TODO: better exception here throw new Exception("A single edge needs at least one target."); } ConvertUnknownProperties(edge, myTargetType); }
override public UpdateBase GetUpdateObjectAction(string _Function, string _classname, object _target) { IBaseType ttype = GetLType(_classname); if (ttype == null) { return(null); } Action tact = GetCSLEDelegate <Action>(_Function, ttype, _target); if (tact == null) { return(null); } return(new UpdateObject(string.Format("{0}->{1}", _classname, _Function), new Method_Action(tact), _target)); }
private void CheckPostConstructsAndInjectableMethods(IBaseType baseObj) { var bindingFlags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance; var methods = baseObj.ImplType.GetMethods(bindingFlags); foreach (var m in methods) { if (m.IsDefined(typeof(PostConstruct), true)) { baseObj.PostConstructs.Add(m); } else if (m.IsDefined(typeof(InjectableParams))) { baseObj.InjectableMethods.Add(m); } } }
public static XmlSchemaSet GetSchema() { if (baseSchema != Fields.FieldsManager.FieldTypesXSD || generatedSchema == null) { baseSchema = Fields.FieldsManager.FieldTypesXSD; XmlSchemaSet s = new XmlSchemaSet(); s.Add(baseSchema); XmlSchema sc = new XmlSchema(); XmlSchema sc2 = new XmlSchema(); XmlSchemaElement sc2elm = new XmlSchemaElement(); sc2elm.Name = "TypesValue"; sc2elm.SchemaTypeName = new XmlQualifiedName("Types"); sc2.Items.Add(sc2elm); XmlSchemaComplexType sc2s = new XmlSchemaComplexType(); sc2s.Name = "Types"; sc2.Items.Add(sc2s); XmlSchemaChoice sc2ch = new XmlSchemaChoice(); sc2s.Particle = sc2ch; foreach (var i in Fields.FieldsManager.FieldTypes) { IBaseType fld = (IBaseType)Fields.FieldsManager.GetInstance(i); fld.TypeName = i.Name + "0"; sc.Items.Add(fld.TypeSchema); } foreach (var i in Fields.FieldsManager.FieldTypes) { XmlSchemaElement el = new XmlSchemaElement(); el.Name = i.Name; el.SchemaTypeName = new XmlQualifiedName(i.Name + "0"); sc2ch.Items.Add(el); } s.Add(sc); s.Add(sc2); s.Compile(); generatedSchema = s; } return(generatedSchema); }
override public void SetMember(IBaseType _type, int _index, object _object, object _target) { if (_type == null) { return; } FieldInfo[] infos = _type.TypeForCLR.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (_index >= infos.Length) { throw new System.ArgumentNullException(string.Format("Base SetMember _index 越界 index = {0} Fieldinfo数组长度 = {1}", _index, infos.Length)); } FieldInfo pi = infos[_index]; if (pi == null) { throw new NullReferenceException("SYS SetMember pi = null ,_index = " + _index); } pi.SetValue(_target, _object); }
override public object GetMemberByIndex(IBaseType _type, int _index, object _object) { if (_type == null) { throw new NullReferenceException("Base GetMember _type = null"); } FieldInfo[] infos = _type.TypeForCLR.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); if (_index >= infos.Length) { throw new System.ArgumentNullException(string.Format("Base GetMember _index 越界 index = {0} Fieldinfo数组长度 = ", _index, infos.Length)); } FieldInfo pi = infos[_index]; if (pi == null) { throw new NullReferenceException("Base GetMember FieldInfo pi = null"); } return(pi.GetValue(_object)); }
virtual protected void InitScriptOnAwake() { if (string.IsNullOrEmpty(mScriptClass) || mInitScript) { return; } try { mCodeTool = GameCore.CodeTool; mScriptType = mCodeTool.GetLType(mScriptClass); mObject = mCodeTool.GetObject(mScriptClass, this); InitParamList(); InitInterface(); mInitScript = true; } catch (Exception _erro) { DLog.LogError(string.Format("脚本初始化出错:Class = {0},GameObject = {1},InitScript ->{2}", mScriptClass, gameObject.name, _erro.ToString())); } }
public override bool EqualsTo(IBaseType value) { // If collection, compare each element if (value is AbstractCollection) { var thisList = AsEnumerable().ToList(); var valueList = (value as AbstractCollection).AsEnumerable().ToList(); if (thisList.Count != valueList.Count) { return false; } for (int i = 0; i < thisList.Count; ++i) { if (thisList[i].NotEqualsTo(valueList[i])) { return false; } } return true; } // else compare by integer (which will mean size) return ToInt() == value.ToInt(); }
public override bool IsDescendant(IBaseType myOtherType) { return((myOtherType is IEdgeType) ? _ServiceToken.EdgeTypeService.IsDescendantByEdgeType(_ServiceToken.SecurityToken, _ServiceToken.TransactionToken, new ServiceEdgeType(this), new ServiceEdgeType((IEdgeType)myOtherType)) : false); }
/// <summary> /// Transforms an IVertex in an incoming edge definition. /// </summary> /// <param name="myVertex">A vertex that represents an incoming edge definition.</param> /// <returns>An incoming edge definition.</returns> public IIncomingEdgeDefinition CreateIncomingEdgeDefinition(IVertex myVertex, IBaseType myDefiningType = null) { var attributeID = GetUUID(myVertex); var name = GetAttributeDotName(myVertex); var related = GetRelatedOutgoingEdgeDefinition(myVertex); var definingType = myDefiningType ?? GetDefiningType(myVertex); var isUserDefined = GetAttributeDotIsUserDefined(myVertex); return(new IncomingEdgeDefinition { Name = name, RelatedEdgeDefinition = related, RelatedType = definingType, ID = myVertex.VertexID, IsUserDefined = isUserDefined, }); }
public IEnumerable <IPropertyDefinition> GetPropertiesFromFS(IVertex myTypeVertex, IBaseType myBaseType = null) { return(GetAttributeVertices(myTypeVertex, (long)BaseTypes.Property).Select(x => CreatePropertyDefinition(x, myBaseType))); }
private void CheckSingleEdge(EdgePredefinition edge, IBaseType myTargetType) { if (edge.ContainedEdges != null) { //TODO better exception here. throw new Exception("A single edge can not contain other edges."); } if (edge.VertexIDsByVertexTypeID == null && edge.VertexIDsByVertexTypeName == null) //TODO: better exception here throw new Exception("A single edge needs at least one target."); ConvertUnknownProperties(edge, myTargetType); }
private static void ConvertUnknownProperties(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.UnknownProperties != null) { foreach (var unknownProp in myPropertyProvider.UnknownProperties) { //ASK: What's about binary properties? if (myBaseType.HasProperty(unknownProp.Key)) { var propDef = myBaseType.GetPropertyDefinition(unknownProp.Key); try { var converted = unknownProp.Value.ConvertToIComparable(propDef.BaseType); myPropertyProvider.AddStructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { //TODO: better exception throw new Exception("Type of property does not match."); } } else { myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, unknownProp.Value); } } myPropertyProvider.ClearUnknown(); } }
private static Dictionary<long, IComparable> ConvertStructuredProperties(IPropertyProvider myInsertDefinition, IBaseType myType) { return (myInsertDefinition.StructuredProperties == null) ? null : myInsertDefinition.StructuredProperties.ToDictionary(x => myType.GetAttributeDefinition(x.Key).ID, x => x.Value); }
protected static void ConvertUnknownProperties(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.UnknownProperties != null) { foreach (var unknownProp in myPropertyProvider.UnknownProperties) { //ASK: What's about binary properties? if (myBaseType.HasProperty(unknownProp.Key)) { var propDef = myBaseType.GetPropertyDefinition(unknownProp.Key); try { IComparable converted = null; if (propDef.Multiplicity == PropertyMultiplicity.List || propDef.Multiplicity == PropertyMultiplicity.Set) { converted = unknownProp.Value.ConvertToIComparableList(propDef.BaseType); } else { if (propDef.BaseType.IsSubclassOf(typeof(AUserdefinedDataType))) { var userdefType = (AUserdefinedDataType)Activator.CreateInstance(propDef.BaseType, new object[] { unknownProp.Value.ConvertToIComparable(typeof(String)) as String }); if (userdefType != null) { converted = userdefType; } } else { converted = unknownProp.Value.ConvertToIComparable(propDef.BaseType); } } myPropertyProvider.AddStructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { //TODO: better exception throw new Exception("Type of property does not match."); } } else { IComparable converted = null; try { if (unknownProp.Value is IEnumerable <Object> ) { if (((IEnumerable <Object>)unknownProp.Value).Count() > 1) { converted = unknownProp.Value.ConvertToIComparableList(typeof(object)); } else { converted = unknownProp.Value.ConvertToIComparable(typeof(object)); } } else { converted = unknownProp.Value.ConvertToIComparable(typeof(object)); } myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, unknownProp.Value); } } } myPropertyProvider.ClearUnknown(); } }
public TestFactory(IBaseType type) { }
public override bool EqualsTo(IBaseType value) { var otherQueueRep = value.ToPriorityQueue().rep; var leftIter = rep.GetEnumerator(); var rightIter = otherQueueRep.GetEnumerator(); bool leftOver = false; bool rightOver = false; while ((leftOver = leftIter.MoveNext()) && (rightOver = rightIter.MoveNext())) { if (!leftIter.Current.Equals(rightIter.Current)) { return false; } leftOver = rightOver = false; } if (leftOver || rightOver) { return false; } return true; }
protected static void ConvertUnknownProperties(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.UnknownProperties != null) { foreach (var unknownProp in myPropertyProvider.UnknownProperties) { //ASK: What's about binary properties? if (myBaseType.HasProperty(unknownProp.Key)) { var propDef = myBaseType.GetPropertyDefinition(unknownProp.Key); try { IComparable converted = null; if (propDef.Multiplicity == PropertyMultiplicity.List || propDef.Multiplicity == PropertyMultiplicity.Set) converted = unknownProp.Value.ConvertToIComparableList(propDef.BaseType); else converted = unknownProp.Value.ConvertToIComparable(propDef.BaseType); myPropertyProvider.AddStructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { //TODO: better exception throw new Exception("Type of property does not match."); } } else { IComparable converted = null; try { if (unknownProp.Value is IEnumerable<Object>) if (((IEnumerable<Object>)unknownProp.Value).Count() > 1) converted = unknownProp.Value.ConvertToIComparableList(typeof(object)); else converted = unknownProp.Value.ConvertToIComparable(typeof(object)); else converted = unknownProp.Value.ConvertToIComparable(typeof(object)); myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, converted); } catch (InvalidCastException) { myPropertyProvider.AddUnstructuredProperty(unknownProp.Key, unknownProp.Value); } } } myPropertyProvider.ClearUnknown(); } }
protected void CheckMandatoryConstraint(IPropertyProvider myPropertyProvider, IBaseType myType) { var mandatories = myType.GetPropertyDefinitions(true).Where(IsMustSetProperty).ToArray(); foreach (var mand in mandatories) { if (myPropertyProvider == null || myPropertyProvider.StructuredProperties == null || !myPropertyProvider.StructuredProperties.Any(x => mand.Name.Equals(x.Key))) { throw new MandatoryConstraintViolationException(mand.Name); } } }
/// <summary> /// Transforms an IVertex in a property definition. /// </summary> /// <param name="myVertex">A vertex that represents a property definition.</param> /// <returns>A property definition.</returns> public static IPropertyDefinition CreatePropertyDefinition(IVertex myVertex, IBaseType myDefiningType = null) { var attributeID = GetUUID(myVertex); var baseType = GetBaseType(myVertex); var isMandatory = GetIsMandatory(myVertex); var multiplicity = GetPropertyMultiplicity(myVertex); var name = GetAttributeDotName(myVertex); var defaultValue = GetDefaultValue(myVertex, baseType); var definingType = myDefiningType ?? GetDefiningType(myVertex); var inIndices = GetInIndices(myVertex); var isUserDefined = GetAttributeDotIsUserDefined(myVertex); return new PropertyDefinition { BaseType = baseType, IsMandatory = isMandatory, Multiplicity = multiplicity, Name = name, RelatedType = definingType, DefaultValue = defaultValue, InIndices = inIndices, ID = myVertex.VertexID, IsUserDefined = isUserDefined, }; }
public override IVertexView CreateResult(IBaseType myAlteredType) { throw new NotImplementedException(); }
/// <summary> /// Creates the result of altering a type /// </summary> /// <param name="myAlteredVertexType">The type that has been altered</param> /// <returns>A vertex view</returns> public abstract IVertexView CreateResult(IBaseType myAlteredType);
public override bool EqualsTo(IBaseType value) { if (value == null) return false; if (value.GetType() != typeof(Struct)) return false; if (!StructuralEquals(value as Struct)) return false; foreach (var item in (value as Struct).Attributes) if (!item.Value.Value.EqualsTo(Attributes[item.Key].Value)) return false; return true; }
/// <summary> /// Transforms an IVertex in an incoming edge definition. /// </summary> /// <param name="myVertex">A vertex that represents an incoming edge definition.</param> /// <returns>An incoming edge definition.</returns> public static IIncomingEdgeDefinition CreateIncomingEdgeDefinition(IVertex myVertex, IBaseType myDefiningType = null) { var attributeID = GetUUID(myVertex); var name = GetAttributeDotName(myVertex); var related = GetRelatedOutgoingEdgeDefinition(myVertex); var definingType = myDefiningType ?? GetDefiningType(myVertex); var isUserDefined = GetAttributeDotIsUserDefined(myVertex); return new IncomingEdgeDefinition { Name = name, RelatedEdgeDefinition = related, RelatedType = definingType, ID = myVertex.VertexID, IsUserDefined = isUserDefined, }; }
/// <summary> /// Check for default values. /// If a default value is set for the property, than we add this to the insert definition. /// </summary> /// <param name="myPropertyProvider">The insert definition.</param> /// <param name="myBaseType">The vertex type, which is to be updated.</param> private static void ConvertDefaultValues(IPropertyProvider myPropertyProvider, IBaseType myBaseType) { if (myPropertyProvider.StructuredProperties != null) { var checkForDefaultValues = myBaseType.GetPropertyDefinitions(true).Where(item => !myPropertyProvider.StructuredProperties.ContainsKey(item.Name)).Where(_ => _.DefaultValue != null); foreach (var item in checkForDefaultValues) { myPropertyProvider.AddStructuredProperty(item.Name, item.DefaultValue); } } }
public override bool IsDescendantOrSelf(IBaseType myOtherType) { return((myOtherType is IVertexType) ? _ServiceToken.VertexTypeService.IsDescendantOrSelfByVertexType(_ServiceToken.SecurityToken, _ServiceToken.TransactionToken, new ServiceVertexType(this), new ServiceVertexType((IVertexType)myOtherType)) : false); }
public override bool EqualsTo(IBaseType value) { return referencedValue.EqualsTo(value); }
public static IEnumerable<IPropertyDefinition> GetPropertiesFromFS(IVertex myTypeVertex, IBaseType myBaseType = null) { return GetAttributeVertices(myTypeVertex, (long)BaseTypes.Property).Select(x => CreatePropertyDefinition(x, myBaseType)); }
public override bool EqualsTo(IBaseType value) { return value.ToNull().IsNull; }
private StructuredPropertiesUpdate CreateStructuredUpdate(IDictionary<string, IComparable> myStructured, IBaseType myVertexType) { if (myStructured == null) return null; return new StructuredPropertiesUpdate(myStructured.ToDictionary(_ => myVertexType.GetAttributeDefinition(_.Key).ID, _ => _.Value)); }
public override bool IsDescendant(IBaseType myOtherType) { return (myOtherType is IEdgeType) ? _ServiceToken.EdgeTypeService.IsDescendantByEdgeType(_ServiceToken.SecurityToken, _ServiceToken.TransactionToken, new ServiceEdgeType(this), new ServiceEdgeType((IEdgeType)myOtherType)) : false; }
public override bool IsDescendantOrSelf(IBaseType myOtherType) { return (myOtherType is IVertexType) ? _ServiceToken.VertexTypeService.IsDescendantOrSelfByVertexType(_ServiceToken.SecurityToken, _ServiceToken.TransactionToken, new ServiceVertexType(this), new ServiceVertexType((IVertexType)myOtherType)) : false; }