protected private override void SetProps(object spiral) { base.SetProps(spiral); AlignmentSpiralConstraintType = GetConstraint2(spiral); A = ReflectionSupport.GetProperty(spiral, "A", double.NaN); K = ReflectionSupport.GetProperty(spiral, "K", double.NaN); P = ReflectionSupport.GetProperty(spiral, "P", double.NaN); Compound = ReflectionSupport.GetProperty(spiral, "Compound", false); CurveType = ReflectionSupport.GetProperty (spiral, "CurveType", C3dDb.SpiralCurveType.InCurve).ToString(); Direction = ReflectionSupport.GetProperty (spiral, "Direction", C3dDb.SpiralDirectionType.DirectionRight).ToString(); ShortTangent = ReflectionSupport.GetProperty(spiral, "ShortTangent", double.NaN); LongTangent = ReflectionSupport.GetProperty(spiral, "LongTangent", double.NaN); MinimumTransitionLength = ReflectionSupport.GetProperty (spiral, "MinimumTransitionLength", double.NaN); _radialPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(spiral, "RadialPoint", null)); RadiusIn = ReflectionSupport.GetProperty(spiral, "RadiusIn", double.NaN); RadiusOut = ReflectionSupport.GetProperty(spiral, "RadiusOut", double.NaN); SPIAngle = ReflectionSupport.GetProperty(spiral, "SPIAngle", double.NaN); _sPIPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(spiral, "SPIPoint", null)); SpiralDefinition = ReflectionSupport.GetProperty (spiral, "SpiralDefinition", C3d.SpiralType.Clothoid).ToString(); SPIStation = ReflectionSupport.GetProperty(spiral, "SPIStation", double.NaN); TotalX = ReflectionSupport.GetProperty(spiral, "TotalX", double.NaN); TotalY = ReflectionSupport.GetProperty(spiral, "TotalY", double.NaN); }
private static void AssignListProperty <TItem>(TItem item, PropertyInfo prop, IEnumerable <AttributeSyntax> matchingAttributes) { var propType = UnderlyingType(prop.PropertyType); var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "AssignListPropertyGeneric", typeof(TItem), propType); concreteMethod.Invoke(null, new object[] { item, prop, matchingAttributes }); }
private static bool TrySetValue(PropertyInfo prop, string propName, object item, object value) { if (prop.Name != propName) { return(false); } return(ReflectionSupport.TrySetPropertyValue(item, propName, value)); }
protected private override void SetProps(object curve) { base.SetProps(curve); StartDirection = ReflectionSupport .GetProperty(curve, "StartDirection", double.NaN); EndDirection = ReflectionSupport .GetProperty(curve, "EndDirection", double.NaN); Delta = ReflectionSupport.GetProperty(curve, "Delta", double.NaN); }
protected private override void SetProps(object line) { base.SetProps(line); Direction = ReflectionSupport.GetProperty(line, "Direction", double.NaN); _midPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(line, "MidPoint", null)); Length = _startPoint.DistanceTo(_endPoint); AlignmentLineConstraintType = GetConstraint2(line); }
/// <summary> /// /// </summary> /// <typeparam name="TMethod"></typeparam> /// <param name="node"></param> /// <returns></returns> /// <remarks> /// Don't be concerned by the lack of references, this is called via reflection /// </remarks> private IEnumerable <TParamItem> GetParsedParametersGeneric <TParamItem>(MethodDeclarationSyntax methodNode) { var ret = new List <TParamItem>(); var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "ParseParameter", typeof(TParamItem)); var parameterNodes = methodNode.GetParameters(); foreach (var parameterNode in parameterNodes) { ret.Add((TParamItem)concreteMethod.Invoke(this, new object[] { parameterNode })); } return(ret); }
/// <summary> /// /// </summary> /// <typeparam name="TMethod"></typeparam> /// <param name="node"></param> /// <returns></returns> /// <remarks> /// Don't be concerned by the lack of references, this is called via reflection /// </remarks> private IEnumerable <TMethodItem> GetParsedMethodsGeneric <TMethodItem>(ClassDeclarationSyntax classNode) { var ret = new List <TMethodItem>(); var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "ParseMethod", typeof(TMethodItem)); var methodNodes = classNode.GetMethods(); foreach (var methodNode in methodNodes) { ret.Add((TMethodItem)concreteMethod.Invoke(this, new object[] { methodNode })); } return(ret); }
/// <summary> /// /// </summary> /// <typeparam name="TLevel"></typeparam> /// <param name="node"></param> /// <param name="nestedLevel"></param> /// <param name="assignments"></param> /// <returns> /// While the gnarly part of this class is partially in the reflection work, /// the guts of the class is this method /// </returns> private TTarget ParseLevel <TTarget, TDom>(TDom domItem, IEnumerable <IDom> nextLevel, params LookupSet <TDom>[] assignments) where TTarget : CodeFirstMetadata.Common.CodeFirstMetadata { var usedAttributes = new List <AttributeSyntax>(); var attributes = node.GetAttributes(); var typeInfo = typeof(TLevel).GetTypeInfo(); var ret = Activator.CreateInstance <TLevel>(); ret.XmlCommentString = node.GetXmlComments(); var props = ReflectionSupport.GetAllProperties(typeInfo, typeof(KadMetadata)).Where(x => x.CanWrite); foreach (var prop in props) { var assigned = false; foreach (var assignment in assignments) { if (TrySetValue(prop, assignment.Item1, ret, assignment.Item2.Invoke(node))) { assigned = true; break; } } if (!assigned) { var matchingAttributes = attributes.Where(x => x.Name.ToString() == prop.Name); if (IsPropertyList(prop)) { var underlyingType = UnderlyingType(prop.PropertyType); if (IsTypeComplex(underlyingType)) { var list = nestedLevel.Invoke(node, underlyingType); prop.SetValue(ret, list); } else { AssignListProperty(ret, prop, matchingAttributes); } } else { AssignSimpleProperty(ret, prop, matchingAttributes); } usedAttributes.AddRange(matchingAttributes); } } var unusedAttributes = attributes.Except(usedAttributes); AddExplicitAttributes(ret, unusedAttributes); return(ret); }
private IEnumerable GetParsedMethods <TDom>(TDom domItem, System.Reflection.TypeInfo propType) { var ret = new List <TMethodItem>(); var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "ParseMethod", typeof(TMethodItem)); var methodNodes = classNode.GetMethods(); foreach (var methodNode in methodNodes) { ret.Add((TMethodItem)concreteMethod.Invoke(this, new object[] { methodNode })); } return(ret); var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "GetParsedMethodsGeneric", propType); return((IEnumerable)concreteMethod.Invoke(this, new object[] { classNode })); }
/// <summary> /// /// </summary> /// <param name="arc"></param> protected private override void SetProps(object arc) { base.SetProps(arc); _centerPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(arc, "CenterPoint", null)); ChordDirection = ReflectionSupport.GetProperty(arc, "ChordDirection", double.NaN); ChordLength = ReflectionSupport.GetProperty(arc, "ChordLength", double.NaN); Clockwise = ReflectionSupport.GetProperty(arc, "Clockwise", false); AlignmentArcConstraintType = GetConstraint2(arc); DeflectedAngle = ReflectionSupport.GetProperty(arc, "DeflectedAngle", double.NaN); ExternalSecant = ReflectionSupport.GetProperty(arc, "ExternalSecant", double.NaN); ExternalTangent = ReflectionSupport.GetProperty(arc, "ExternalTangent", double.NaN); GreaterThan180 = ReflectionSupport.GetProperty(arc, "GreaterThan180", false); MidOrdinate = ReflectionSupport.GetProperty(arc, "MidOrdinate", double.NaN); MinimumRadius = ReflectionSupport.GetProperty(arc, "MinimumRadius", double.NaN); PIStation = ReflectionSupport.GetProperty(arc, "PIStation", double.NaN); Radius = ReflectionSupport.GetProperty(arc, "Radius", double.NaN); ReverseCurve = ReflectionSupport.GetProperty(arc, "ReverseCurve", false); }
/// <summary> /// Raises the property changed event. /// </summary> /// <typeparam name="T">The Type.</typeparam> /// <param name="propertyExpression">The property expression.</param> public void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { var propertyName = ReflectionSupport.GetPropertyName(propertyExpression); RaisePropertyChanged(propertyName); }
private IEnumerable GetParsedParameters(SyntaxNode methodNode, Type propType) { var concreteMethod = ReflectionSupport.MakeMethod(typeof(ParserForMetadata <T>), "GetParsedParametersGeneric", propType); return((IEnumerable)concreteMethod.Invoke(this, new object[] { methodNode })); }
internal AlignmentArc(C3dDb.AlignmentSubEntityArc subEntityArc) : base(subEntityArc) { _pIPoint = PointData.FromPointObject (ReflectionSupport.GetProperty(subEntityArc, "PIPoint", null)); }