internal static PQR CreatePQR(UseContext context) { return(new PQR((decimal)1.23, "284196006", "2.16.840.1.113883.6.96" )); }
public static void Trace(string message, UseContext context) { #if DEBUG // string indent = context != null ? context.Indent : string.Empty; //System.Diagnostics.Trace.WriteLine(indent + message); #endif }
internal static CO CreateCO(UseContext context) { return(new CO((decimal)1.23, new CD <string>( "284196006", "2.16.840.1.113883.6.96" ))); }
internal static RTO<IQuantity, IQuantity> CreateRtoDefault(UseContext context) { var res = CreateRtoOfPqAndPq(context); return new RTO<IQuantity, IQuantity>( res.Numerator, res.Denominator ); }
internal static CE <String> CreateCE(UseContext context) { return(new CE <String>() { Code = "284196006", CodeSystem = "2.16.840.1.113883.6.96" }); }
internal static string CreateString(UseContext context) { Tracer.Trace("Creating string", context); return (context.ParameterInfo != null ? context.ParameterInfo.Name : context.PropertyInfo != null ? context.PropertyInfo.Name : "String"); }
internal static RTO <IQuantity, IQuantity> CreateRtoDefault(UseContext context) { var res = CreateRtoOfPqAndPq(context); return(new RTO <IQuantity, IQuantity>( res.Numerator, res.Denominator )); }
internal static ON CreateON(UseContext context) { return(new ON(EntityNameUse.Legal, new ENXP[] { new ENXP("St", EntityNamePartType.Prefix), new ENXP("Mary's", EntityNamePartType.Suffix) })); }
internal static string CreateString(UseContext context) { Tracer.Trace("Creating string", context); return context.ParameterInfo != null ? context.ParameterInfo.Name : context.PropertyInfo != null ? context.PropertyInfo.Name : "String"; }
internal static PN CreatePN(UseContext context) { Tracer.Trace("Creating PN", context); PN result = new PN(); result.Part.Add(new ENXP("McLovin", EntityNamePartType.Family)); return(result); }
internal static PIVL <TS> CreatePIVLTS(UseContext context) { Tracer.Trace("Creating PIVL", context); PIVL <TS> result = new PIVL <TS>( CreateIVLTS(context), new PQ((decimal)1.0, "d") ); return(result); }
internal static CD <String> CreateCD(UseContext context) { Tracer.Trace("Creating CD", context); return(new CD <String>() { Code = "284196006", CodeSystem = "2.16.840.1.113883.6.96" }); }
internal static IVL <PQ> CreateIVLPQ(UseContext context) { Tracer.Trace("Creating IVL<PQ>", context); IVL <PQ> result = new IVL <PQ>(); result.Low = new PQ((decimal)1, "d"); result.High = new PQ((decimal)3, "d"); return(result); }
internal static IVL <TS> CreateIVLTS(UseContext context) { Tracer.Trace("Creating IVL<TS>", context); IVL <TS> result = new IVL <TS>(); result.Low = CreateTS(context); result.High = CreateTS(context).DateValue.AddDays(1); return(result); }
internal static MO CreateMO(UseContext context) { Tracer.Trace("Creating MO", context); MO result = new MO(); result.Value = 1000000001; result.Currency = "CAD"; return(result); }
internal static EN CreateEN(UseContext context) { return(new EN(EntityNameUse.Legal, new ENXP[] { new ENXP("John", EntityNamePartType.Given), new ENXP("Jacob", EntityNamePartType.Given), new ENXP("Jingleheimer", EntityNamePartType.Family), new ENXP("-", EntityNamePartType.Delimiter), new ENXP("Schmidt", EntityNamePartType.Given) } )); }
//internal static ResponseMode CreateResponseMode(UseContext context) //{ // Tracer.Trace("Creating ResponseMode", context); // return ResponseMode.Immediate; //} //internal static QueryRequestLimit CreateQueryRequestLimit(UseContext context) //{ // Tracer.Trace("Creating QueryRequestLimit", context); // return QueryRequestLimit.Record; //} internal static URG <PQ> CreateURG_PQ(UseContext context) { Tracer.Trace("Creating URG<PQ>", context); URG <PQ> result = new URG <PQ>(); result.Value = (decimal)Math.PI; result.Probability = (decimal)0.9999999999999; return(result); }
/// <summary> /// Create a CS /// </summary> /// <param name="context"></param> /// <returns></returns> internal static CS <String> CreateCS(UseContext context) { Tracer.Trace("Creating CS", context); if (context.PropertyAttribute != null && context.PropertyAttribute.Name == "moodCode") { return(new CS <string>("EVN")); } return(new CS <String>() { Code = "PPP" }); }
internal static RTO <MO, PQ> CreateRtoOfMoAndPq(UseContext context) { Tracer.Trace("Creating RTO<MO,PQ>", context); RTO <MO, PQ> result = new RTO <MO, PQ>(); result.Numerator = new MO(); result.Denominator = new PQ(); result.Numerator.Value = 1000000001; result.Numerator.Currency = "CAD"; result.Denominator.Unit = "day"; result.Denominator.Value = 1; return(result); }
internal static RTO<MO, PQ> CreateRtoOfMoAndPq(UseContext context) { Tracer.Trace("Creating RTO<MO,PQ>", context); RTO<MO, PQ> result = new RTO<MO, PQ>(); result.Numerator = new MO(); result.Denominator = new PQ(); result.Numerator.Value = 1000000001; result.Numerator.Currency = "CAD"; result.Denominator.Unit = "day"; result.Denominator.Value = 1; return result; }
internal static AD CreateAD(UseContext context) { List <ADXP> result = new List <ADXP>(); result.Add(new ADXP("123", AddressPartType.BuildingNumber)); result.Add(new ADXP("Fake", AddressPartType.StreetNameBase)); result.Add(new ADXP("Street", AddressPartType.StreetType)); result.Add(new ADXP("1", AddressPartType.UnitIdentifier)); result.Add(new ADXP("Door", AddressPartType.UnitDesignator)); result.Add(new ADXP("Anytown", AddressPartType.City)); result.Add(new ADXP("AnyCounty", AddressPartType.County)); result.Add(new ADXP("Ontario", AddressPartType.State)); result.Add(new ADXP("Canada", AddressPartType.Country)); AD ad = new AD(PostalAddressUse.HomeAddress, result); return(ad); }
private object CreateCollection(Type collectionType, Type elementType, UseContext context) { int count = 1; if (null != context && null != context.PropertyAttribute) { //if (context.PropertyAttribute.MaxOccurs > context.PropertyAttribute.MinOccurs) //{ // count = m_Random.Next(context.PropertyAttribute.MinOccurs, context.PropertyAttribute.MaxOccurs + 1); // } //else //{ if (context.PropertyAttribute.MinOccurs != 0) { count = context.PropertyAttribute.MinOccurs; } //} } return(CreateCollection(collectionType, elementType, count, context)); }
internal static INT CreateINT(UseContext context) { Tracer.Trace("Creating INT", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { switch (context.PropertyAttribute.ImposeFlavorId) { case "INT.POS": return(22); case "INT.NONNEG": return(0); default: return(-42); } } else { return(55); } }
internal static II CreateII(UseContext context) { Tracer.Trace("Creating II", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { switch (context.PropertyAttribute.ImposeFlavorId) { case "II.BUS": return(new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", ""))); case "II.TOKEN": return(new II(Guid.NewGuid())); default: return(new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", ""))); } } else //Return the default { return(new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", ""))); } }
internal static TEL CreateTEL(UseContext context) { Tracer.Trace("Creating TEL", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { TEL result = new TEL(); if (null == result.Use) result.Use = new SET<CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>>(); switch (context.PropertyAttribute.ImposeFlavorId) { case "TEL.URI": #region URI result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return result; #endregion case "TEL.PHONE": #region Phone result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.WorkPlace); result.Value = "+1-905-575-1212x3112"; return result; #endregion case "TEL.PHONEMAIL": #region Email result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.WorkPlace); result.Value = "mailto:[email protected]"; return result; #endregion default: #region Default - URI result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return result; #endregion } } else { #region Unknown - Assume URI TEL result = new TEL(); if (null == result.Use) result.Use = new SET<CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>>(); result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return result; #endregion } }
internal static TEL CreateTEL(UseContext context) { Tracer.Trace("Creating TEL", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { TEL result = new TEL(); if (null == result.Use) { result.Use = new SET <CS <MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse> >(); } switch (context.PropertyAttribute.ImposeFlavorId) { case "TEL.URI": #region URI result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return(result); #endregion case "TEL.PHONE": #region Phone result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.WorkPlace); result.Value = "+1-905-575-1212x3112"; return(result); #endregion case "TEL.PHONEMAIL": #region Email result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.WorkPlace); result.Value = "mailto:[email protected]"; return(result); #endregion default: #region Default - URI result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return(result); #endregion } } else { #region Unknown - Assume URI TEL result = new TEL(); if (null == result.Use) { result.Use = new SET <CS <MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse> >(); } result.Use.Add(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Direct); result.Value = "http://www.marc-hi.ca"; return(result); #endregion } }
//internal static ResponseMode CreateResponseMode(UseContext context) //{ // Tracer.Trace("Creating ResponseMode", context); // return ResponseMode.Immediate; //} //internal static QueryRequestLimit CreateQueryRequestLimit(UseContext context) //{ // Tracer.Trace("Creating QueryRequestLimit", context); // return QueryRequestLimit.Record; //} internal static URG<PQ> CreateURG_PQ(UseContext context) { Tracer.Trace("Creating URG<PQ>", context); URG<PQ> result = new URG<PQ>(); result.Value = (decimal)Math.PI; result.Probability = (decimal)0.9999999999999; return result; }
internal static II CreateII(UseContext context) { Tracer.Trace("Creating II", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { switch (context.PropertyAttribute.ImposeFlavorId) { case "II.BUS": return new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", "")); case "II.TOKEN": return new II(Guid.NewGuid()); default: return new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", "")); } } else //Return the default { return new II("1.2.3.4", Guid.NewGuid().ToString().Replace("{", "").Replace("}", "")); } }
internal static ST CreateST(UseContext context) { Tracer.Trace("Creating ST", context); return "String"; }
private bool IsChoice(Type t, UseContext context) { return(null != context && null != context.PropertyInfo && null != context.PropertyAttribute && (t == typeof(object) || t.IsAbstract)); }
internal static TN CreateTN(UseContext context) { return(new TN("Bob The Builder")); }
internal static GTS CreateGTS(UseContext context) { Tracer.Trace("Create GTS", context); return(new GTS(new IVL <TS>(CreateTS(context), CreateTS(context)))); }
internal static PN CreatePN(UseContext context) { Tracer.Trace("Creating PN", context); PN result = new PN(); result.Part.Add(new ENXP("McLovin", EntityNamePartType.Family)); return result; }
internal static ED CreateED(UseContext context) { return(new ED(new byte[] { 0, 1, 1, 2, 3, 5, 8, 13 }, "other/fibanacci")); }
private object CreateComplexObject(Type t, UseContext context) { //Tracer.Trace(string.Format("CreateComplexObject of type {0}", t.GetCSharpGenericName()), context); if (context.PropertyAttribute != null) if (context.PropertyAttribute.Conformance == MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Optional) if (context.PropertyAttributes.Count == 1) //Not a choice if (null != context.PropertyInfo && context.PropertyInfo.PropertyType == t) return null; ConstructorInfo ctor = null; object result = null; // Missing CMET? if (context.PropertyAttribute != null && context.PropertyAttribute.Type == null && context.PropertyAttributes.Count == 1 && t == typeof(System.Object)) return null; //if (m_MandatoryConstructorCache.ContainsKey(t)) // ctor = m_MandatoryConstructorCache[t]; if (m_EmptyConstructorCache.ContainsKey(t)) ctor = m_EmptyConstructorCache[t]; if (null == ctor) ctor = t.GetConstructor(Type.EmptyTypes); if (null == ctor) //No Constructors available for the given type return null; var ctorparms = ctor.GetParameters(); if (ctorparms.Length > 0) { List<object> ctorparmvalues = new List<object>(); foreach (var ctorparm in ctorparms) { ctorparmvalues.Add(CreateType(ctorparm.ParameterType, new UseContext(t, ctorparm) { ParentContext = context } )); } result = ctor.Invoke(ctorparmvalues.ToArray()); } else { result = ctor.Invoke(null); } PopulateObject(result, t, context); return result; }
internal static CE<String> CreateCE(UseContext context) { return new CE<String>() { Code = "284196006", CodeSystem = "2.16.840.1.113883.6.96" }; }
internal static GTS CreateGTS(UseContext context) { Tracer.Trace("Create GTS", context); return new GTS(new IVL<TS>(CreateTS(context), CreateTS(context))); }
internal static PQR CreatePQR(UseContext context) { return new PQR((decimal)1.23, "284196006", "2.16.840.1.113883.6.96" ); }
internal static CO CreateCO(UseContext context) { return new CO((decimal)1.23, new CD<string>( "284196006", "2.16.840.1.113883.6.96" )); }
internal static CD<String> CreateCD(UseContext context) { Tracer.Trace("Creating CD", context); return new CD<String>() { Code = "284196006", CodeSystem = "2.16.840.1.113883.6.96" }; }
private object CreateCollection(Type collectionType, Type elementType, int count, UseContext context) { //Tracer.Trace(string.Format("Creating collection of type {0}", collectionType.GetCSharpGenericName()), context); var ctor = collectionType.GetConstructor(Type.EmptyTypes); if (null == ctor) { return(null); } var addmethod = collectionType.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance); if (null == addmethod) { return(null); } object o = ctor.Invoke(null); if (null != context && null != context.PropertyAttribute) { if (context.PropertyAttribute.MaxOccurs == 0) { return(o); //No Items permitted, ignore the previous number } } for (int i = 0; i < count; i++) { var t = Util.FromWireFormat(CreateType(elementType, context), elementType); if (t != null) { addmethod.Invoke(o, new object[] { t }); } } return(o); }
internal static SC CreateSC(UseContext context) { Tracer.Trace("Creating SC", context); return new SC("Hello", "en-US", new CD<String>("120394")); }
private void PopulateObject(object o, Type t, UseContext context) { var properties = t.GetProperties(); // JF - Get the DT r1 formatter var allowedProperties = o is HXIT?m_formatter.GetSupportedProperties(t) : properties; foreach (var prop in properties) { //if (prop.Name.ToLower().StartsWith("attentionline")) // System.Diagnostics.Debugger.Break(); if (!Array.Exists <PropertyInfo>(allowedProperties, p => p.Name == prop.Name)) { continue; } // Don't bother with anything from infrastructure root if (prop.Name == "TypeId" || prop.Name == "RealmCode") { continue; } if (!prop.CanWrite) //Not writable, don't even bother { continue; } if (prop.GetIndexParameters().Length > 0) { continue; } if (prop.GetValue(o, null) != null) { if (GetCollectionType(prop.PropertyType) == null) { continue; } else { prop.SetValue(o, CreateCollection(prop.PropertyType, GetCollectionType(prop.PropertyType), new UseContext(o.GetType(), prop) { ParentContext = context }), null); continue; } } if (prop.Name == "NullFlavor") { continue; } if (prop.Name == "NullFlavor") { continue; } try { prop.SetValue(o, ConvertTypeIfNecessary(CreateType(prop.PropertyType, new UseContext(o.GetType(), prop) { ParentContext = context }), prop.PropertyType), null); } catch { //System.Diagnostics.Debugger.Break(); } } }
internal static TN CreateTN(UseContext context) { return new TN("Bob The Builder"); }
/// <summary> /// Recursive createtype method. /// </summary> /// <param name="t">The type to create</param> /// <param name="context">context, if it exists.</param> /// <returns></returns> private object CreateType(Type t, UseContext context) { if (m_TypeStack.Contains(t)) //Prevent Recursion return null; if ((context.Indent.Length > 2 * 10 && DateTime.Now.Subtract(m_startTime).TotalSeconds > 10) && context.PropertyAttribute.Conformance != MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Mandatory && context.PropertyAttribute.Conformance != MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Populated || context.PropertyAttribute != null && context.PropertyAttribute.Conformance == MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Optional && !this.GenerateOptional) return null; if(context.PropertyInfo != null && context.PropertyInfo.Name != null) Tracer.Trace(context.PropertyInfo.Name, context); if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(t)) //Simple creator exists return SimpleTypeCreator.SimpleTypeCreators[t].Invoke(context); if (IsAssignableFromGenericType(t)) if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(GetAssignableGenericType(t))) return SimpleTypeCreator.SimpleTypeCreators[GetAssignableGenericType(t)].Invoke(context); else if (IsEnumeration(GetAssignableGenericType(t))) return AssignRandomEnumerationValue(GetAssignableGenericType(t)); if (IsICollection(t)) //if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(GetCollectionType(t))) return CreateCollection(t, GetCollectionType(t), context); if (IsChoice(t, context)) { UseContext rootContext = context; while (rootContext.ParentContext != null) rootContext = rootContext.ParentContext; if (context.PropertyAttribute.Type != null && !context.PropertyAttribute.Type.IsAbstract && (context.PropertyAttribute.InteractionOwner == rootContext.OwnerType || context.PropertyAttribute.InteractionOwner == null)) return CreateType(context.PropertyAttribute.Type, context); else foreach (var prop in context.PropertyAttributes) if (prop.Type != null && !prop.Type.IsAbstract && (prop.InteractionOwner == rootContext.OwnerType || prop.InteractionOwner == null)) { context.PropertyAttribute = prop; return CreateType(prop.Type, context); } } m_TypeStack.Push(t); //Check if it is a generic type from which object result = CreateComplexObject(t, context); m_TypeStack.Pop(); return result; }
/// <summary> /// Recursive createtype method. /// </summary> /// <param name="t">The type to create</param> /// <param name="context">context, if it exists.</param> /// <returns></returns> private object CreateType(Type t, UseContext context) { if (m_TypeStack.Contains(t)) //Prevent Recursion { return(null); } if ((context.Indent.Length > 2 * 10 && DateTime.Now.Subtract(m_startTime).TotalSeconds > 10) && context.PropertyAttribute.Conformance != MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Mandatory && context.PropertyAttribute.Conformance != MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Populated || context.PropertyAttribute != null && context.PropertyAttribute.Conformance == MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Optional && !this.GenerateOptional) { return(null); } if (context.PropertyInfo != null && context.PropertyInfo.Name != null) { Tracer.Trace(context.PropertyInfo.Name, context); } if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(t)) //Simple creator exists { return(SimpleTypeCreator.SimpleTypeCreators[t].Invoke(context)); } if (IsAssignableFromGenericType(t)) { if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(GetAssignableGenericType(t))) { return(SimpleTypeCreator.SimpleTypeCreators[GetAssignableGenericType(t)].Invoke(context)); } else if (IsEnumeration(GetAssignableGenericType(t))) { return(AssignRandomEnumerationValue(GetAssignableGenericType(t))); } } if (IsICollection(t)) { //if (SimpleTypeCreator.SimpleTypeCreators.ContainsKey(GetCollectionType(t))) return(CreateCollection(t, GetCollectionType(t), context)); } if (IsChoice(t, context)) { UseContext rootContext = context; while (rootContext.ParentContext != null) { rootContext = rootContext.ParentContext; } if (context.PropertyAttribute.Type != null && !context.PropertyAttribute.Type.IsAbstract && (context.PropertyAttribute.InteractionOwner == rootContext.OwnerType || context.PropertyAttribute.InteractionOwner == null)) { return(CreateType(context.PropertyAttribute.Type, context)); } else { foreach (var prop in context.PropertyAttributes) { if (prop.Type != null && !prop.Type.IsAbstract && (prop.InteractionOwner == rootContext.OwnerType || prop.InteractionOwner == null)) { context.PropertyAttribute = prop; return(CreateType(prop.Type, context)); } } } } m_TypeStack.Push(t); //Check if it is a generic type from which object result = CreateComplexObject(t, context); m_TypeStack.Pop(); return(result); }
private object CreateCollection(Type collectionType, Type elementType, UseContext context) { int count = 1; if (null != context && null != context.PropertyAttribute) { //if (context.PropertyAttribute.MaxOccurs > context.PropertyAttribute.MinOccurs) //{ // count = m_Random.Next(context.PropertyAttribute.MinOccurs, context.PropertyAttribute.MaxOccurs + 1); // } //else //{ if(context.PropertyAttribute.MinOccurs != 0) count = context.PropertyAttribute.MinOccurs; //} } return CreateCollection(collectionType, elementType, count, context); }
internal static INT CreateINT(UseContext context) { Tracer.Trace("Creating INT", context); if (null != context && null != context.PropertyAttribute && !string.IsNullOrEmpty(context.PropertyAttribute.ImposeFlavorId)) { switch (context.PropertyAttribute.ImposeFlavorId) { case "INT.POS": return 22; case "INT.NONNEG": return 0; default: return -42; } } else { return 55; } }
/// <summary> /// Create a CS /// </summary> /// <param name="context"></param> /// <returns></returns> internal static CS<String> CreateCS(UseContext context) { Tracer.Trace("Creating CS", context); if(context.PropertyAttribute != null && context.PropertyAttribute.Name == "moodCode") return new CS<string>("EVN"); return new CS<String>() { Code = "PPP" }; }
private object CreateComplexObject(Type t, UseContext context) { //Tracer.Trace(string.Format("CreateComplexObject of type {0}", t.GetCSharpGenericName()), context); if (context.PropertyAttribute != null) { if (context.PropertyAttribute.Conformance == MARC.Everest.Attributes.PropertyAttribute.AttributeConformanceType.Optional) { if (context.PropertyAttributes.Count == 1) //Not a choice { if (null != context.PropertyInfo && context.PropertyInfo.PropertyType == t) { return(null); } } } } ConstructorInfo ctor = null; object result = null; // Missing CMET? if (context.PropertyAttribute != null && context.PropertyAttribute.Type == null && context.PropertyAttributes.Count == 1 && t == typeof(System.Object)) { return(null); } //if (m_MandatoryConstructorCache.ContainsKey(t)) // ctor = m_MandatoryConstructorCache[t]; if (m_EmptyConstructorCache.ContainsKey(t)) { ctor = m_EmptyConstructorCache[t]; } if (null == ctor) { ctor = t.GetConstructor(Type.EmptyTypes); } if (null == ctor) //No Constructors available for the given type { return(null); } var ctorparms = ctor.GetParameters(); if (ctorparms.Length > 0) { List <object> ctorparmvalues = new List <object>(); foreach (var ctorparm in ctorparms) { ctorparmvalues.Add(CreateType(ctorparm.ParameterType, new UseContext(t, ctorparm) { ParentContext = context } )); } result = ctor.Invoke(ctorparmvalues.ToArray()); } else { result = ctor.Invoke(null); } PopulateObject(result, t, context); return(result); }
internal static EN CreateEN(UseContext context) { return new EN(EntityNameUse.Legal, new ENXP[] { new ENXP("John", EntityNamePartType.Given), new ENXP("Jacob", EntityNamePartType.Given), new ENXP("Jingleheimer", EntityNamePartType.Family), new ENXP("-", EntityNamePartType.Delimiter), new ENXP("Schmidt", EntityNamePartType.Given) } ); }
internal static REAL CreateREAL(UseContext context) { Tracer.Trace("Creating REAL", context); return Math.PI; }
internal static ON CreateON(UseContext context) { return new ON(EntityNameUse.Legal, new ENXP[] { new ENXP("St", EntityNamePartType.Prefix), new ENXP("Mary's", EntityNamePartType.Suffix) }); }
private bool IsChoice(Type t, UseContext context) { return null != context && null != context.PropertyInfo && null != context.PropertyAttribute && (t == typeof(object) || t.IsAbstract); }
internal static TS CreateTS(UseContext context) { Tracer.Trace("Creating TS", context); return DateTime.Parse("2011-02-09 12:55:00"); }
private object CreateCollection(Type collectionType, Type elementType, int count, UseContext context) { //Tracer.Trace(string.Format("Creating collection of type {0}", collectionType.GetCSharpGenericName()), context); var ctor = collectionType.GetConstructor(Type.EmptyTypes); if (null == ctor) return null; var addmethod = collectionType.GetMethod("Add", BindingFlags.Public | BindingFlags.Instance); if (null == addmethod) return null; object o = ctor.Invoke(null); if (null != context && null != context.PropertyAttribute) if (context.PropertyAttribute.MaxOccurs == 0) return o; //No Items permitted, ignore the previous number for (int i = 0; i < count; i++) { var t = Util.FromWireFormat(CreateType(elementType, context), elementType); if (t != null) addmethod.Invoke(o, new object[]{ t }); } return o; }
internal static ED CreateED(UseContext context) { return new ED(new byte[] { 0, 1, 1, 2, 3, 5, 8, 13 }, "other/fibanacci"); }
private void PopulateObject(object o, Type t, UseContext context) { var properties = t.GetProperties(); // JF - Get the DT r1 formatter var allowedProperties = o is HXIT ? m_formatter.GetSupportedProperties(t) : properties; foreach (var prop in properties) { //if (prop.Name.ToLower().StartsWith("attentionline")) // System.Diagnostics.Debugger.Break(); if (!Array.Exists<PropertyInfo>(allowedProperties, p => p.Name == prop.Name)) continue; // Don't bother with anything from infrastructure root if (prop.Name == "TypeId" || prop.Name == "RealmCode") continue; if (!prop.CanWrite) //Not writable, don't even bother continue; if (prop.GetIndexParameters().Length > 0) continue; if (prop.GetValue(o, null) != null) if (GetCollectionType(prop.PropertyType) == null) continue; else { prop.SetValue(o, CreateCollection(prop.PropertyType, GetCollectionType(prop.PropertyType), new UseContext(o.GetType(), prop) { ParentContext = context }), null); continue; } if (prop.Name == "NullFlavor") continue; if (prop.Name == "NullFlavor") continue; try { prop.SetValue(o, ConvertTypeIfNecessary(CreateType(prop.PropertyType, new UseContext(o.GetType(), prop) { ParentContext = context }), prop.PropertyType), null); } catch { //System.Diagnostics.Debugger.Break(); } } }
internal static BL CreateBL(UseContext context) { Tracer.Trace("Creating BL", context); return true; }