Пример #1
0
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            XmlSchemaSet xmlSchemaSet;
            XmlSchema xmlSchema;
            ObjectConstruct objectConstruct00;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            using (Stream stream = File.Open(sourceFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                xmlSchema = XmlSchema.Read(stream, ValidationCallback);

            xmlSchemaSet = new XmlSchemaSet();
            xmlSchemaSet.Add(xmlSchema);
            xmlSchemaSet.Compile();

            xmlSchema = xmlSchemaSet.Schemas().Cast<XmlSchema>().ToList()[0];

            EnumSchema(objectConstruct00, xmlSchema.Items);

            return objectConstruct00;
        }
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            ObjectConstruct objectConstruct00;

            List<Assembly> assemblies;
            Assembly assembly;
            IEnumerable<string> filePaths;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            assemblies = new List<Assembly>();
            sourceFilePath = Path.GetFullPath(sourceFilePath);

            if (File.Exists(sourceFilePath))
                filePaths = new string[] { sourceFilePath };
            else if (Directory.Exists(sourceFilePath))
                filePaths = Directory.EnumerateFiles(sourceFilePath, "*.dll", SearchOption.TopDirectoryOnly);
            else
                filePaths = null;

            if ((object)filePaths != null)
            {
                foreach (string filePath in filePaths)
                {
                    assembly = Assembly.LoadFile(filePath);

                    if ((object)assembly == null)
                        throw new InvalidOperationException(string.Format("Failed to load the assembly file '{0}' via Assembly.LoadFile(..).", sourceFilePath));

                    assemblies.Add(assembly);
                }
            }

            objectConstruct00 = new ObjectConstruct();

            ModelAssemblies(assemblies.ToArray(), objectConstruct00);

            return objectConstruct00;
        }
Пример #3
0
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary <string, IList <string> > properties)
        {
            XmlSchemaSet    xmlSchemaSet;
            XmlSchema       xmlSchema;
            ObjectConstruct objectConstruct00;

            if ((object)sourceFilePath == null)
            {
                throw new ArgumentNullException(nameof(sourceFilePath));
            }

            if ((object)properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath))
            {
                throw new ArgumentOutOfRangeException(nameof(sourceFilePath));
            }

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            using (Stream stream = File.Open(sourceFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                xmlSchema = XmlSchema.Read(stream, ValidationCallback);

            xmlSchemaSet = new XmlSchemaSet();
            xmlSchemaSet.Add(xmlSchema);
            xmlSchemaSet.Compile();

            xmlSchema = xmlSchemaSet.Schemas().Cast <XmlSchema>().ToList()[0];

            EnumSchema(objectConstruct00, xmlSchema.Items);

            return(objectConstruct00);
        }
        private static void ModelProperties(PropertyInfo[] propertyInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            ParameterInfo[] parameterInfos;
            MethodInfo methodInfo;

            if ((object)propertyInfos == null)
                throw new ArgumentNullException("propertyInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Properties";
            parent.Items.Add(arrayConstruct00);

            foreach (PropertyInfo propertyInfo in propertyInfos)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyName";
                propertyConstruct00.RawValue = propertyInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyCanRead";
                propertyConstruct00.RawValue = propertyInfo.CanRead;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyCanWrite";
                propertyConstruct00.RawValue = propertyInfo.CanWrite;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyIsSpecialName";
                propertyConstruct00.RawValue = propertyInfo.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyTypeName";
                propertyConstruct00.RawValue = propertyInfo.PropertyType.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyTypeNamespace";
                propertyConstruct00.RawValue = propertyInfo.PropertyType.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyTypeFullName";
                propertyConstruct00.RawValue = propertyInfo.PropertyType.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "PropertyTypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = propertyInfo.PropertyType.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                methodInfo = propertyInfo.GetGetMethod();

                if ((object)methodInfo != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "PropertyGetMethodIsStatic";
                    propertyConstruct00.RawValue = methodInfo.IsStatic;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                methodInfo = propertyInfo.GetSetMethod();

                if ((object)methodInfo != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "PropertySetMethodIsStatic";
                    propertyConstruct00.RawValue = methodInfo.IsStatic;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                ModelCustomAttributes(propertyInfo, objectConstruct00);

                parameterInfos = propertyInfo.GetIndexParameters();

                ModelParameters(parameterInfos, objectConstruct00);
            }
        }
Пример #5
0
        public void SaveModelOnly(ObjectConstruct model, string filePath)
        {
            IXmlPersistEngine xpe;

            if ((object)model == null)
                throw new ArgumentNullException("model");

            if ((object)filePath == null)
                throw new ArgumentNullException("filePath");

            if (DataType.IsWhiteSpace(filePath))
                throw new ArgumentOutOfRangeException("filePath");

            filePath = Path.GetFullPath(filePath);

            xpe = new XmlPersistEngine();
            xpe.RegisterWellKnownConstructs();

            xpe.SerializeToXml(model, filePath);
        }
Пример #6
0
        private static void EnumSchema(IAssociativeXmlObject parentAssociativeXmlObject, XmlSchemaObjectCollection currentXmlSchemaObjectCollection)
        {
            XmlSchemaElement xmlSchemaElement;
            XmlSchemaComplexType xmlSchemaComplexType;
            XmlSchemaSequence xmlSchemaSequence;
            XmlSchemaSimpleType xmlSchemaSimpleType;
            ArrayConstruct arrayConstruct00, arrayConstruct01;
            ObjectConstruct objectConstruct00, objectConstruct01;
            PropertyConstruct propertyConstruct00, propertyConstruct01;

            if ((object)parentAssociativeXmlObject == null)
                throw new ArgumentNullException("parentAssociativeXmlObject");

            if ((object)currentXmlSchemaObjectCollection == null)
                throw new ArgumentNullException("currentXmlSchemaObjectCollection");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "XmlSchemaElements";
            parentAssociativeXmlObject.Items.Add(arrayConstruct00);

            foreach (XmlSchemaObject xmlSchemaObject in currentXmlSchemaObjectCollection)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;

                if ((object)xmlSchemaElement != null)
                {
                    if (DataType.IsNullOrWhiteSpace(xmlSchemaElement.Name) &&
                        !DataType.IsNullOrWhiteSpace(xmlSchemaElement.RefName.Name))
                    {
                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = true;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        continue;
                    }
                    else
                    {
                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = false;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00 = new PropertyConstruct();
                        propertyConstruct00.Name = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        xmlSchemaComplexType = xmlSchemaElement.ElementSchemaType as XmlSchemaComplexType;
                        xmlSchemaSimpleType = xmlSchemaElement.ElementSchemaType as XmlSchemaSimpleType;

                        if ((object)xmlSchemaSimpleType != null)
                        {
                            propertyConstruct00 = new PropertyConstruct();
                            propertyConstruct00.Name = "XmlSchemaElementSimpleType";
                            propertyConstruct00.RawValue = xmlSchemaSimpleType.Datatype.TypeCode;
                            objectConstruct00.Items.Add(propertyConstruct00);
                        }
                        else if ((object)xmlSchemaComplexType != null)
                        {
                            arrayConstruct01 = new ArrayConstruct();
                            arrayConstruct01.Name = "XmlSchemaAttributes";
                            objectConstruct00.Items.Add(arrayConstruct01);

                            if ((object)xmlSchemaComplexType.Attributes != null)
                            {
                                foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes)
                                {
                                    objectConstruct01 = new ObjectConstruct();
                                    arrayConstruct01.Items.Add(objectConstruct01);

                                    propertyConstruct01 = new PropertyConstruct();
                                    propertyConstruct01.Name = "XmlSchemaElementLocalName";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Name;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01 = new PropertyConstruct();
                                    propertyConstruct01.Name = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Namespace;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01 = new PropertyConstruct();
                                    propertyConstruct01.Name = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.AttributeSchemaType.TypeCode;
                                    objectConstruct01.Items.Add(propertyConstruct01);
                                }
                            }

                            xmlSchemaSequence = xmlSchemaComplexType.ContentTypeParticle as XmlSchemaSequence;

                            if ((object)xmlSchemaSequence != null)
                                EnumSchema(objectConstruct00, xmlSchemaSequence.Items);
                        }
                    }
                }
            }
        }
        private static void ModelMethods(MethodInfo[] methodInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            ParameterInfo[] parameterInfos;
            Type[] childTypes;

            if ((object)methodInfos == null)
                throw new ArgumentNullException("methodInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Methods";
            parent.Items.Add(arrayConstruct00);

            foreach (MethodInfo methodInfo in methodInfos)
            {
                if (!IsRealMemberInfo(methodInfo))
                    continue;

                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodName";
                propertyConstruct00.RawValue = methodInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodCallingConvention";
                propertyConstruct00.RawValue = methodInfo.CallingConvention;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodContainsGenericParameters";
                propertyConstruct00.RawValue = methodInfo.ContainsGenericParameters;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsAbstract";
                propertyConstruct00.RawValue = methodInfo.IsAbstract;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsAssembly";
                propertyConstruct00.RawValue = methodInfo.IsAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsConstructor";
                propertyConstruct00.RawValue = methodInfo.IsConstructor;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsFamily";
                propertyConstruct00.RawValue = methodInfo.IsFamily;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsFamilyAndAssembly";
                propertyConstruct00.RawValue = methodInfo.IsFamilyAndAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsFamilyOrAssembly";
                propertyConstruct00.RawValue = methodInfo.IsFamilyOrAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsFinal";
                propertyConstruct00.RawValue = methodInfo.IsFinal;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsGenericMethod";
                propertyConstruct00.RawValue = methodInfo.IsGenericMethod;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsGenericMethodDefinition";
                propertyConstruct00.RawValue = methodInfo.IsGenericMethodDefinition;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsHideBySig";
                propertyConstruct00.RawValue = methodInfo.IsHideBySig;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsPrivate";
                propertyConstruct00.RawValue = methodInfo.IsPrivate;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsPublic";
                propertyConstruct00.RawValue = methodInfo.IsPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsSecurityCritical";
                propertyConstruct00.RawValue = methodInfo.IsSecurityCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsSecuritySafeCritical";
                propertyConstruct00.RawValue = methodInfo.IsSecuritySafeCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsSecurityTransparent";
                propertyConstruct00.RawValue = methodInfo.IsSecurityTransparent;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsSpecialName";
                propertyConstruct00.RawValue = methodInfo.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsStatic";
                propertyConstruct00.RawValue = methodInfo.IsStatic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodIsVirtual";
                propertyConstruct00.RawValue = methodInfo.IsVirtual;
                objectConstruct00.Items.Add(propertyConstruct00);
            #if !__MonoCS__
                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodImplementationFlags";
                propertyConstruct00.RawValue = methodInfo.MethodImplementationFlags;
                objectConstruct00.Items.Add(propertyConstruct00);
            #endif
                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodReturnTypeName";
                propertyConstruct00.RawValue = methodInfo.ReturnType.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodReturnTypeNamespace";
                propertyConstruct00.RawValue = methodInfo.ReturnType.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodReturnTypeFullName";
                propertyConstruct00.RawValue = methodInfo.ReturnType.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "MethodReturnTypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = methodInfo.ReturnType.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                if (methodInfo.IsGenericMethod)
                {
                    var _methodInfo = methodInfo.GetGenericMethodDefinition();

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "MethodGenericMethodDefinitionName";
                    propertyConstruct00.RawValue = _methodInfo.DeclaringType.Name;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "MethodGenericMethodDefinitionNamespace";
                    propertyConstruct00.RawValue = _methodInfo.DeclaringType.Namespace;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "MethodGenericMethodDefinitionFullName";
                    propertyConstruct00.RawValue = _methodInfo.DeclaringType.FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "MethodGenericMethodDefinitionAssemblyQualifiedName";
                    propertyConstruct00.RawValue = _methodInfo.DeclaringType.AssemblyQualifiedName;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                ModelCustomAttributes(methodInfo, objectConstruct00);

                parameterInfos = methodInfo.GetParameters();
                Array.Resize(ref parameterInfos, parameterInfos.Length + 1);
                parameterInfos[parameterInfos.Length - 1] = methodInfo.ReturnParameter;

                ModelParameters(parameterInfos, objectConstruct00);

                childTypes = methodInfo.GetGenericArguments();

                ModelTypes("GenericArguments", childTypes, objectConstruct00);
            }
        }
        private static void ModelEvents(EventInfo[] eventInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            MethodInfo methodInfo;

            if ((object)eventInfos == null)
                throw new ArgumentNullException("eventInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Events";
            parent.Items.Add(arrayConstruct00);

            foreach (EventInfo eventInfo in eventInfos)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventName";
                propertyConstruct00.RawValue = eventInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventHandlerTypeName";
                propertyConstruct00.RawValue = eventInfo.EventHandlerType.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventHandlerTypeNamespace";
                propertyConstruct00.RawValue = eventInfo.EventHandlerType.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventHandlerTypeFullName";
                propertyConstruct00.RawValue = eventInfo.EventHandlerType.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventHandlerTypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = eventInfo.EventHandlerType.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventIsMulticast";
                propertyConstruct00.RawValue = eventInfo.IsMulticast;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "EventIsSpecialName";
                propertyConstruct00.RawValue = eventInfo.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                methodInfo = eventInfo.GetAddMethod();

                if ((object)methodInfo != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "EventAddMethodIsStatic";
                    propertyConstruct00.RawValue = methodInfo.IsStatic;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                methodInfo = eventInfo.GetRemoveMethod();

                if ((object)methodInfo != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "EventRemoveMethodIsStatic";
                    propertyConstruct00.RawValue = methodInfo.IsStatic;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                methodInfo = eventInfo.GetRaiseMethod();

                if ((object)methodInfo != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "EventRaiseMethodIsStatic";
                    propertyConstruct00.RawValue = methodInfo.IsStatic;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                ModelCustomAttributes(eventInfo, objectConstruct00);
            }
        }
        private static void ModelAssemblyReferences(AssemblyName[] assemblyReferences, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            ObjectConstruct objectConstruct00;

            if ((object)assemblyReferences == null)
                throw new ArgumentNullException("assemblyReferences");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "AssemblyReferences";
            parent.Items.Add(arrayConstruct00);

            foreach (AssemblyName assemblyReference in assemblyReferences)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                ModelAssemblyName(assemblyReference, objectConstruct00);
            }
        }
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary <string, IList <string> > properties)
        {
            const string      PROP_TOKEN_RECURSIVE = "Recursive";
            const string      PROP_TOKEN_WILDCARD  = "Wildcard";
            ObjectConstruct   objectConstruct00;
            PropertyConstruct propertyConstruct00;
            IList <string>    values;
            bool   recursive = false;
            string recursiveStr;
            string wildcard;

            if ((object)sourceFilePath == null)
            {
                throw new ArgumentNullException(nameof(sourceFilePath));
            }

            if ((object)properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath))
            {
                throw new ArgumentOutOfRangeException(nameof(sourceFilePath));
            }

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            recursiveStr = null;
            if (properties.TryGetValue(PROP_TOKEN_RECURSIVE, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    recursiveStr = values[0];
                    if (!SolderFascadeAccessor.DataTypeFascade.TryParse <bool>(recursiveStr, out recursive))
                    {
                        // do nothing
                    }
                }
            }

            wildcard = null;
            if (properties.TryGetValue(PROP_TOKEN_WILDCARD, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    wildcard = values[0];
                }
            }

            objectConstruct00 = new ObjectConstruct();

            propertyConstruct00          = new PropertyConstruct();
            propertyConstruct00.Name     = "SourceFullPath";
            propertyConstruct00.RawValue = sourceFilePath;
            objectConstruct00.Items.Add(propertyConstruct00);

            propertyConstruct00          = new PropertyConstruct();
            propertyConstruct00.Name     = "Recursive";
            propertyConstruct00.RawValue = recursive;
            objectConstruct00.Items.Add(propertyConstruct00);

            propertyConstruct00          = new PropertyConstruct();
            propertyConstruct00.Name     = "Wildcard";
            propertyConstruct00.RawValue = wildcard;
            objectConstruct00.Items.Add(propertyConstruct00);

            EnumerateFileSystem(sourceFilePath, recursive, wildcard, objectConstruct00, sourceFilePath);

            return(objectConstruct00);
        }
        private static void EnumerateFileSystem(string directoryPath, bool recursive, string wildcard, AssociativeXmlObject parent, string sourcePath)
        {
            ArrayConstruct    arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct   objectConstruct00;

            ArrayConstruct    arrayConstruct01;
            PropertyConstruct propertyConstruct01;
            ObjectConstruct   objectConstruct01;

            string[] directories;
            string[] files;

            if ((object)directoryPath == null)
            {
                throw new ArgumentNullException(nameof(directoryPath));
            }

            if ((object)parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            arrayConstruct00      = new ArrayConstruct();
            arrayConstruct00.Name = "Files";
            parent.Items.Add(arrayConstruct00);

            arrayConstruct01      = new ArrayConstruct();
            arrayConstruct01.Name = "Directories";
            parent.Items.Add(arrayConstruct01);

            if (File.Exists(directoryPath))
            {
                files       = new string[] { Path.GetFullPath(directoryPath) };
                directories = null;
            }
            else
            {
                if (SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(wildcard))
                {
                    files = Directory.GetFiles(directoryPath);
                }
                else
                {
                    files = Directory.GetFiles(directoryPath, wildcard);
                }

                if (SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(wildcard))
                {
                    directories = Directory.GetDirectories(directoryPath);
                }
                else
                {
                    directories = Directory.GetDirectories(directoryPath, wildcard);
                }
            }

            if ((object)files != null)
            {
                foreach (string file in files)
                {
                    FileInfo fileInfo;

                    fileInfo = new FileInfo(file);

                    objectConstruct00 = new ObjectConstruct();
                    arrayConstruct00.Items.Add(objectConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileFullName";
                    propertyConstruct00.RawValue = fileInfo.FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileFullNameRelativeToSource";
                    propertyConstruct00.RawValue = EvaluateRelativePath2(sourcePath, fileInfo.FullName);
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileCreationTime";
                    propertyConstruct00.RawValue = fileInfo.CreationTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileCreationTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.CreationTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileExtension";
                    propertyConstruct00.RawValue = fileInfo.Extension;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileIsReadOnly";
                    propertyConstruct00.RawValue = fileInfo.IsReadOnly;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileLastAccessTime";
                    propertyConstruct00.RawValue = fileInfo.LastAccessTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileLastAccessTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.LastAccessTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileLastWriteTime";
                    propertyConstruct00.RawValue = fileInfo.LastWriteTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileLastWriteTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.LastWriteTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileLength";
                    propertyConstruct00.RawValue = fileInfo.Length;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00          = new PropertyConstruct();
                    propertyConstruct00.Name     = "FileName";
                    propertyConstruct00.RawValue = fileInfo.Name;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }
            }

            if ((object)directories != null)
            {
                foreach (string directory in directories)
                {
                    DirectoryInfo directoryInfo;

                    directoryInfo = new DirectoryInfo(directory);

                    objectConstruct01 = new ObjectConstruct();
                    arrayConstruct01.Items.Add(objectConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryFullName";
                    propertyConstruct01.RawValue = directoryInfo.FullName;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryFullNameRelativeToSource";
                    propertyConstruct01.RawValue = EvaluateRelativePath2(sourcePath, directoryInfo.FullName);
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryAttributes";
                    propertyConstruct01.RawValue = directoryInfo.Attributes;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryCreationTime";
                    propertyConstruct01.RawValue = directoryInfo.CreationTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryCreationTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.CreationTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryExtension";
                    propertyConstruct01.RawValue = directoryInfo.Extension;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryLastAccessTime";
                    propertyConstruct01.RawValue = directoryInfo.LastAccessTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryLastAccessTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.LastAccessTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryLastWriteTime";
                    propertyConstruct01.RawValue = directoryInfo.LastWriteTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryLastWriteTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.LastWriteTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01          = new PropertyConstruct();
                    propertyConstruct01.Name     = "DirectoryName";
                    propertyConstruct01.RawValue = directoryInfo.Name;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    if (recursive)
                    {
                        EnumerateFileSystem(directory, recursive, wildcard, objectConstruct01, sourcePath);
                    }
                }
            }
        }
Пример #12
0
        private static void EnumSchema(IAssociativeXmlObject parentAssociativeXmlObject, XmlSchemaObjectCollection currentXmlSchemaObjectCollection)
        {
            XmlSchemaElement     xmlSchemaElement;
            XmlSchemaComplexType xmlSchemaComplexType;
            XmlSchemaSequence    xmlSchemaSequence;
            XmlSchemaSimpleType  xmlSchemaSimpleType;
            ArrayConstruct       arrayConstruct00, arrayConstruct01;
            ObjectConstruct      objectConstruct00, objectConstruct01;
            PropertyConstruct    propertyConstruct00, propertyConstruct01;

            if ((object)parentAssociativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(parentAssociativeXmlObject));
            }

            if ((object)currentXmlSchemaObjectCollection == null)
            {
                throw new ArgumentNullException(nameof(currentXmlSchemaObjectCollection));
            }

            arrayConstruct00      = new ArrayConstruct();
            arrayConstruct00.Name = "XmlSchemaElements";
            parentAssociativeXmlObject.Items.Add(arrayConstruct00);

            foreach (XmlSchemaObject xmlSchemaObject in currentXmlSchemaObjectCollection)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                xmlSchemaElement = xmlSchemaObject as XmlSchemaElement;

                if ((object)xmlSchemaElement != null)
                {
                    if (SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(xmlSchemaElement.Name) &&
                        !SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(xmlSchemaElement.RefName.Name))
                    {
                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = true;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.RefName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        continue;
                    }
                    else
                    {
                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementIsRef";
                        propertyConstruct00.RawValue = false;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementLocalName";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Name;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        propertyConstruct00          = new PropertyConstruct();
                        propertyConstruct00.Name     = "XmlSchemaElementNamespace";
                        propertyConstruct00.RawValue = xmlSchemaElement.QualifiedName.Namespace;
                        objectConstruct00.Items.Add(propertyConstruct00);

                        xmlSchemaComplexType = xmlSchemaElement.ElementSchemaType as XmlSchemaComplexType;
                        xmlSchemaSimpleType  = xmlSchemaElement.ElementSchemaType as XmlSchemaSimpleType;

                        if ((object)xmlSchemaSimpleType != null)
                        {
                            propertyConstruct00          = new PropertyConstruct();
                            propertyConstruct00.Name     = "XmlSchemaElementSimpleType";
                            propertyConstruct00.RawValue = xmlSchemaSimpleType.Datatype.TypeCode;
                            objectConstruct00.Items.Add(propertyConstruct00);
                        }
                        else if ((object)xmlSchemaComplexType != null)
                        {
                            arrayConstruct01      = new ArrayConstruct();
                            arrayConstruct01.Name = "XmlSchemaAttributes";
                            objectConstruct00.Items.Add(arrayConstruct01);

                            if ((object)xmlSchemaComplexType.Attributes != null)
                            {
                                foreach (XmlSchemaAttribute xmlSchemaAttribute in xmlSchemaComplexType.Attributes)
                                {
                                    objectConstruct01 = new ObjectConstruct();
                                    arrayConstruct01.Items.Add(objectConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementLocalName";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Name;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.QualifiedName.Namespace;
                                    objectConstruct01.Items.Add(propertyConstruct01);

                                    propertyConstruct01          = new PropertyConstruct();
                                    propertyConstruct01.Name     = "XmlSchemaElementNamespace";
                                    propertyConstruct01.RawValue = xmlSchemaAttribute.AttributeSchemaType.TypeCode;
                                    objectConstruct01.Items.Add(propertyConstruct01);
                                }
                            }

                            xmlSchemaSequence = xmlSchemaComplexType.ContentTypeParticle as XmlSchemaSequence;

                            if ((object)xmlSchemaSequence != null)
                            {
                                EnumSchema(objectConstruct00, xmlSchemaSequence.Items);
                            }
                        }
                    }
                }
            }
        }
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary <string, IList <string> > properties)
        {
            const string PROP_TOKEN_FIRST_RECORD_CONTAINS_COLUMN_HEADINGS = "FirstRecordIsHeader";
            const string PROP_TOKEN_HEADER_NAMES     = "HeaderName";
            const string PROP_TOKEN_FIELD_DELIMITER  = "FieldDelimiter";
            const string PROP_TOKEN_RECORD_DELIMITER = "RecordDelimiter";
            const string PROP_TOKEN_QUOTE_VALUE      = "QuoteValue";

            IList <string> values;
            bool           firstRecordIsHeader;
            string         recordDelimiter;
            string         fieldDelimiter;
            string         quoteValue;

            string[] headerNames;

            ObjectConstruct   objectConstruct00;
            ArrayConstruct    arrayConstruct00;
            ObjectConstruct   objectConstruct01;
            PropertyConstruct propertyConstruct01;

            string line;

            string[] headers = null;

            ObjectConstruct tempOc;

            if ((object)sourceFilePath == null)
            {
                throw new ArgumentNullException(nameof(sourceFilePath));
            }

            if ((object)properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath))
            {
                throw new ArgumentOutOfRangeException(nameof(sourceFilePath));
            }

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            firstRecordIsHeader = false;
            if (properties.TryGetValue(PROP_TOKEN_FIRST_RECORD_CONTAINS_COLUMN_HEADINGS, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    if (!SolderFascadeAccessor.DataTypeFascade.TryParse <bool>(values[0], out firstRecordIsHeader))
                    {
                        firstRecordIsHeader = false;
                    }
                }
            }

            headerNames = null;
            if (properties.TryGetValue(PROP_TOKEN_HEADER_NAMES, out values))
            {
                if ((object)values != null)
                {
                    headerNames = values.ToArray();
                }
            }

            fieldDelimiter = string.Empty;
            if (properties.TryGetValue(PROP_TOKEN_FIELD_DELIMITER, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    fieldDelimiter = values[0];
                }
            }

            recordDelimiter = string.Empty;
            if (properties.TryGetValue(PROP_TOKEN_RECORD_DELIMITER, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    recordDelimiter = values[0];
                }
            }

            quoteValue = string.Empty;
            if (properties.TryGetValue(PROP_TOKEN_QUOTE_VALUE, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    quoteValue = values[0];
                }
            }

            if (!SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(fieldDelimiter))
            {
                fieldDelimiter = fieldDelimiter.Replace("\\\\t", "\t");
                fieldDelimiter = fieldDelimiter.Replace("\\\\r", "\r");
                fieldDelimiter = fieldDelimiter.Replace("\\\\n", "\n");
                fieldDelimiter = fieldDelimiter.Replace("\\\"", "\"");
            }

            if (!SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(recordDelimiter))
            {
                recordDelimiter = recordDelimiter.Replace("\\\\t", "\t");
                recordDelimiter = recordDelimiter.Replace("\\\\r", "\r");
                recordDelimiter = recordDelimiter.Replace("\\\\n", "\n");
                recordDelimiter = recordDelimiter.Replace("\\\"", "\"");
            }

            if (!SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(quoteValue))
            {
                quoteValue = quoteValue.Replace("\\\\t", "\t");
                quoteValue = quoteValue.Replace("\\\\r", "\r");
                quoteValue = quoteValue.Replace("\\\\n", "\n");
                quoteValue = quoteValue.Replace("\\\"", "\"");
            }

            tempOc = objectConstruct01 = new ObjectConstruct();
            objectConstruct01.Name = "DelimitedTextSpec";
            objectConstruct00.Items.Add(objectConstruct01);

            propertyConstruct01 = new PropertyConstruct()
            {
                Name  = "FirstRecordIsHeader",
                Value = firstRecordIsHeader.ToString()
            };
            objectConstruct01.Items.Add(propertyConstruct01);

            propertyConstruct01 = new PropertyConstruct()
            {
                Name  = "RecordDelimiter",
                Value = recordDelimiter
            };
            objectConstruct01.Items.Add(propertyConstruct01);

            propertyConstruct01 = new PropertyConstruct()
            {
                Name  = "FieldDelimiter",
                Value = fieldDelimiter
            };
            objectConstruct01.Items.Add(propertyConstruct01);

            propertyConstruct01 = new PropertyConstruct()
            {
                Name  = "QuoteValue",
                Value = quoteValue
            };
            objectConstruct01.Items.Add(propertyConstruct01);

            using (StreamReader streamReader = File.OpenText(sourceFilePath))
            {
                int i = 0;

                arrayConstruct00      = new ArrayConstruct();
                arrayConstruct00.Name = "Records";
                objectConstruct00.Items.Add(arrayConstruct00);

                while ((line = (streamReader.ReadLine() ?? string.Empty)).Trim() != string.Empty)
                {
                    string[] fields;

                    fields = line.Split(fieldDelimiter.ToCharArray());

                    if (firstRecordIsHeader && i == 0)
                    {
                        headers = fields;
                        i++;
                        continue;
                    }

                    objectConstruct01 = new ObjectConstruct();
                    arrayConstruct00.Items.Add(objectConstruct01);

                    if ((object)fields != null)
                    {
                        int j = 0;

                        foreach (string field in fields)
                        {
                            propertyConstruct01 = new PropertyConstruct();

                            if (firstRecordIsHeader && (object)headers != null)
                            {
                                propertyConstruct01.Name = string.Format("{0}", headers[j++]);
                            }
                            else
                            {
                                propertyConstruct01.Name = string.Format("Field{0}", (j++) + 1);
                            }

                            propertyConstruct01.RawValue = field;
                            objectConstruct01.Items.Add(propertyConstruct01);
                        }
                    }

                    i++;
                }
            }

            return(objectConstruct00);
        }
Пример #14
0
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            const string PROP_TOKEN_CONNECTION_AQTN = "ConnectionType";
            const string PROP_TOKEN_CONNECTION_STRING = "ConnectionString";
            const string PROP_TOKEN_GET_SCHEMA_ONLY = "GetSchemaOnly";
            string connectionAqtn;
            Type connectionType = null;
            string connectionString = null;
            bool getSchemaOnly = false;
            IList<string> values;

            ObjectConstruct objectConstruct00;
            SqlQuery sqlQuery;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            connectionAqtn = null;
            if (properties.TryGetValue(PROP_TOKEN_CONNECTION_AQTN, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    connectionAqtn = values[0];
                    connectionType = Type.GetType(connectionAqtn, false);
                }
            }

            if ((object)connectionType == null)
                throw new InvalidOperationException(string.Format("Failed to load the connection type '{0}' via Type.GetType(..).", connectionAqtn));

            if (!typeof(IDbConnection).IsAssignableFrom(connectionType))
                throw new InvalidOperationException(string.Format("The connection type is not assignable to type '{0}'.", typeof(IDbConnection).FullName));

            if (properties.TryGetValue(PROP_TOKEN_CONNECTION_STRING, out values))
            {
                if ((object)values != null && values.Count == 1)
                    connectionString = values[0];
            }

            if (DataType.IsWhiteSpace(connectionString))
                throw new InvalidOperationException(string.Format("The connection string cannot be null or whitespace."));

            if (properties.TryGetValue(PROP_TOKEN_GET_SCHEMA_ONLY, out values))
            {
                if ((object)values != null && values.Count == 1)
                    DataType.TryParse<bool>(values[0], out getSchemaOnly);
            }

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            sqlQuery = Cerealization.GetObjectFromFile<SqlQuery>(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            WriteSqlQuery(new SqlQuery[] { sqlQuery }, objectConstruct00, connectionType, connectionString, getSchemaOnly);

            return objectConstruct00;
        }
Пример #15
0
        private static void WriteSqlQuery(IEnumerable<SqlQuery> sqlQueries, IAssociativeXmlObject parentAssociativeXmlObject, Type connectionType, string connectionString, bool getSchemaOnly)
        {
            ArrayConstruct arrayConstruct;
            ObjectConstruct objectConstruct;
            PropertyConstruct propertyConstruct;
            Tokenizer tokenizer;

            IList<IDictionary<string, object>> objs;
            string commandText;
            int rcecordsAffected;

            if ((object)sqlQueries == null)
                throw new ArgumentNullException("sqlQueries");

            if ((object)parentAssociativeXmlObject == null)
                throw new ArgumentNullException("parentAssociativeXmlObject");

            if ((object)connectionType == null)
                throw new ArgumentNullException("connectionType");

            if ((object)connectionString == null)
                throw new ArgumentNullException("connectionString");

            if (DataType.IsWhiteSpace(connectionString))
                throw new ArgumentOutOfRangeException("connectionString");

            tokenizer = new Tokenizer(true);

            foreach (SqlQuery sqlQuery in sqlQueries.OrderBy(c => c.Key).ThenBy(c => c.Order))
            {
                arrayConstruct = new ArrayConstruct();
                arrayConstruct.Name = sqlQuery.Key;
                parentAssociativeXmlObject.Items.Add(arrayConstruct);

                commandText = tokenizer.ExpandTokens(sqlQuery.Text, new DynamicWildcardTokenReplacementStrategy(new object[] { parentAssociativeXmlObject }));

                using (IUnitOfWorkContext unitOfWorkContext = UnitOfWorkContext.Create(connectionType, connectionString, false))
                {
                    if (!getSchemaOnly)
                        objs = unitOfWorkContext.ExecuteDictionary(sqlQuery.Type, commandText, null, out rcecordsAffected);
                    else
                        objs = unitOfWorkContext.ExecuteSchema(sqlQuery.Type, commandText, null);
                }

                if ((object)objs != null)
                {
                    propertyConstruct = new PropertyConstruct();
                    propertyConstruct.Name = "RowCount";
                    propertyConstruct.RawValue = objs.Count;
                    arrayConstruct.Items.Add(propertyConstruct);

                    foreach (IDictionary<string, object> obj in objs)
                    {
                        objectConstruct = new ObjectConstruct();
                        arrayConstruct.Items.Add(objectConstruct);

                        if ((object)obj != null)
                        {
                            foreach (KeyValuePair<string, object> keyValuePair in obj)
                            {
                                propertyConstruct = new PropertyConstruct();
                                propertyConstruct.Name = keyValuePair.Key;
                                propertyConstruct.RawValue = keyValuePair.Value;

                                objectConstruct.Items.Add(propertyConstruct);
                            }
                        }

                        // correlated
                        WriteSqlQuery(sqlQuery.SubQueries, objectConstruct, connectionType, connectionString, getSchemaOnly);
                    }
                }
            }
        }
Пример #16
0
        private static void ModelTypes(string arrayName, Type[] types, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            FieldInfo[] fieldInfos;
            PropertyInfo[] propertyInfos;
            MethodInfo[] methodInfos;
            EventInfo[] eventInfos;
            ConstructorInfo[] constructorInfos;

            Type[] childTypes;

            if ((object)types == null)
                throw new ArgumentNullException("types");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = arrayName;
            parent.Items.Add(arrayConstruct00);

            foreach (Type type in types)
            {
                Console.WriteLine("{0} ==> '{1}'", arrayName, type.FullName);

                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeName";
                propertyConstruct00.RawValue = type.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeNamespace";
                propertyConstruct00.RawValue = type.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeFullName";
                propertyConstruct00.RawValue = type.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = type.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                if ((object)type.BaseType != null)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeBaseName";
                    propertyConstruct00.RawValue = type.BaseType.Name;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeBaseNamespace";
                    propertyConstruct00.RawValue = type.BaseType.Namespace;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeBaseFullName";
                    propertyConstruct00.RawValue = type.BaseType.FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeBaseAssemblyQualifiedName";
                    propertyConstruct00.RawValue = type.BaseType.AssemblyQualifiedName;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeGuid";
                propertyConstruct00.RawValue = type.GUID;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsAbstract";
                propertyConstruct00.RawValue = type.IsAbstract;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsAnsiClass";
                propertyConstruct00.RawValue = type.IsAnsiClass;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsArray";
                propertyConstruct00.RawValue = type.IsArray;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsAutoClass";
                propertyConstruct00.RawValue = type.IsAutoClass;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsAutoLayout";
                propertyConstruct00.RawValue = type.IsAutoLayout;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsByRef";
                propertyConstruct00.RawValue = type.IsByRef;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsClass";
                propertyConstruct00.RawValue = type.IsClass;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsComObject";
                propertyConstruct00.RawValue = type.IsCOMObject;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsConstructedGenericType";
                propertyConstruct00.RawValue = type.IsConstructedGenericType;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsContextful";
                propertyConstruct00.RawValue = type.IsContextful;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsEnum";
                propertyConstruct00.RawValue = type.IsEnum;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsExplicitLayout";
                propertyConstruct00.RawValue = type.IsExplicitLayout;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsGenericParameter";
                propertyConstruct00.RawValue = type.IsGenericParameter;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsGenericType";
                propertyConstruct00.RawValue = type.IsGenericType;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsGenericTypeDefinition";
                propertyConstruct00.RawValue = type.IsGenericTypeDefinition;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsImport";
                propertyConstruct00.RawValue = type.IsImport;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsInterface";
                propertyConstruct00.RawValue = type.IsInterface;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsLayoutSequential";
                propertyConstruct00.RawValue = type.IsLayoutSequential;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsMarshalByRef";
                propertyConstruct00.RawValue = type.IsMarshalByRef;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNested";
                propertyConstruct00.RawValue = type.IsNested;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedAssembly";
                propertyConstruct00.RawValue = type.IsNestedAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedFamANDAssem";
                propertyConstruct00.RawValue = type.IsNestedFamANDAssem;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedFamORAssem";
                propertyConstruct00.RawValue = type.IsNestedFamORAssem;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedFamily";
                propertyConstruct00.RawValue = type.IsNestedFamily;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedPrivate";
                propertyConstruct00.RawValue = type.IsNestedPrivate;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNestedPublic";
                propertyConstruct00.RawValue = type.IsNestedPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsNotPublic";
                propertyConstruct00.RawValue = type.IsNotPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsPointer";
                propertyConstruct00.RawValue = type.IsPointer;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsPrimitive";
                propertyConstruct00.RawValue = type.IsPrimitive;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsPublic";
                propertyConstruct00.RawValue = type.IsPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSealed";
                propertyConstruct00.RawValue = type.IsSealed;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSecurityCritical";
                propertyConstruct00.RawValue = type.IsSecurityCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSecuritySafeCritical";
                propertyConstruct00.RawValue = type.IsSecuritySafeCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSecurityTransparent";
                propertyConstruct00.RawValue = type.IsSecurityTransparent;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSerializable";
                propertyConstruct00.RawValue = type.IsSerializable;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsSpecialName";
                propertyConstruct00.RawValue = type.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsUnicodeClass";
                propertyConstruct00.RawValue = type.IsUnicodeClass;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsValueType";
                propertyConstruct00.RawValue = type.IsValueType;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeIsVisible";
                propertyConstruct00.RawValue = type.IsVisible;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeNamespace";
                propertyConstruct00.RawValue = type.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "TypeContainsGenericParameters";
                propertyConstruct00.RawValue = type.ContainsGenericParameters;
                objectConstruct00.Items.Add(propertyConstruct00);

                if (type.IsGenericParameter)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericParameterAttributes";
                    propertyConstruct00.RawValue = type.GenericParameterAttributes;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericParameterPosition";
                    propertyConstruct00.RawValue = type.GenericParameterPosition;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                if (type.IsGenericType)
                {
                    var _type = type.GetGenericTypeDefinition();

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericTypeDefinitionName";
                    propertyConstruct00.RawValue = _type.Name;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericTypeDefinitionNamespace";
                    propertyConstruct00.RawValue = _type.Namespace;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericTypeDefinitionFullName";
                    propertyConstruct00.RawValue = _type.FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "TypeGenericTypeDefinitionAssemblyQualifiedName";
                    propertyConstruct00.RawValue = _type.AssemblyQualifiedName;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                ModelCustomAttributes(type, objectConstruct00);

                fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelFields(fieldInfos, objectConstruct00);

                propertyInfos = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelProperties(propertyInfos, objectConstruct00);

                methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelMethods(methodInfos, objectConstruct00);

                eventInfos = type.GetEvents(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelEvents(eventInfos, objectConstruct00);

                constructorInfos = type.GetConstructors(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelConstructors(constructorInfos, objectConstruct00);

                childTypes = type.GenericTypeArguments;

                ModelTypes("GenericTypeArguments", childTypes, objectConstruct00);

                childTypes = type.GetGenericArguments();

                ModelTypes("GenericArguments", childTypes, objectConstruct00);

                if (type.IsGenericParameter)
                {
                    childTypes = type.GetGenericParameterConstraints();

                    ModelTypes("GenericParameterConstraints", childTypes, objectConstruct00);
                }

                childTypes = type.GetNestedTypes(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

                ModelTypes("NestedTypes", childTypes, objectConstruct00);
            }
        }
Пример #17
0
        private static void ModelAssemblies(Assembly[] assemblies, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            Type[] types;
            AssemblyName[] assemblyReferences;
            AssemblyName assemblyName;

            if ((object)assemblies == null)
                throw new ArgumentNullException("assemblies");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Assemblies";
            parent.Items.Add(arrayConstruct00);

            foreach (Assembly assembly in assemblies)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyLoadedFromGlobalAssemblyCache";
                propertyConstruct00.RawValue = assembly.GlobalAssemblyCache;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyImageRuntimeVersion";
                propertyConstruct00.RawValue = assembly.ImageRuntimeVersion;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyIsDynamic";
                propertyConstruct00.RawValue = assembly.IsDynamic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyIsFullyTrusted";
                propertyConstruct00.RawValue = assembly.IsFullyTrusted;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyReflectionOnly";
                propertyConstruct00.RawValue = assembly.ReflectionOnly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyFullName";
                propertyConstruct00.RawValue = assembly.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyLocation";
                propertyConstruct00.RawValue = assembly.Location;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyManifestModuleName";
                propertyConstruct00.RawValue = assembly.ManifestModule.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyManifestModuleVersionId";
                propertyConstruct00.RawValue = assembly.ManifestModule.ModuleVersionId;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyManifestModuleFullyQualifiedName";
                propertyConstruct00.RawValue = assembly.ManifestModule.FullyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyManifestModuleMDStreamVersion";
                propertyConstruct00.RawValue = assembly.ManifestModule.MDStreamVersion;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "AssemblyManifestModuleScopeName";
                propertyConstruct00.RawValue = assembly.ManifestModule.ScopeName;
                objectConstruct00.Items.Add(propertyConstruct00);

                //ModelCustomAttributes(assembly.ManifestModule, objectConstruct00);

                assemblyName = assembly.GetName();

                ModelAssemblyName(assemblyName, objectConstruct00);

                ModelCustomAttributes(assembly, objectConstruct00);

                types = assembly.GetExportedTypes();

                ModelTypes("Types", types, objectConstruct00);

                assemblyReferences = assembly.GetReferencedAssemblies();

                ModelAssemblyReferences(assemblyReferences, objectConstruct00);
            }
        }
Пример #18
0
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            const string PROP_TOKEN_RECURSIVE = "Recursive";
            const string PROP_TOKEN_WILDCARD = "Wildcard";
            ObjectConstruct objectConstruct00;
            PropertyConstruct propertyConstruct00;
            IList<string> values;
            bool recursive = false;
            string recursiveStr;
            string wildcard;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            recursiveStr = null;
            if (properties.TryGetValue(PROP_TOKEN_RECURSIVE, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    recursiveStr = values[0];
                    if (!DataType.TryParse<bool>(recursiveStr, out recursive))
                        ;
                }
            }

            wildcard = null;
            if (properties.TryGetValue(PROP_TOKEN_WILDCARD, out values))
            {
                if ((object)values != null && values.Count == 1)
                    wildcard = values[0];
            }

            objectConstruct00 = new ObjectConstruct();

            propertyConstruct00 = new PropertyConstruct();
            propertyConstruct00.Name = "SourceFullPath";
            propertyConstruct00.RawValue = sourceFilePath;
            objectConstruct00.Items.Add(propertyConstruct00);

            propertyConstruct00 = new PropertyConstruct();
            propertyConstruct00.Name = "Recursive";
            propertyConstruct00.RawValue = recursive;
            objectConstruct00.Items.Add(propertyConstruct00);

            propertyConstruct00 = new PropertyConstruct();
            propertyConstruct00.Name = "Wildcard";
            propertyConstruct00.RawValue = wildcard;
            objectConstruct00.Items.Add(propertyConstruct00);

            EnumerateFileSystem(sourceFilePath, recursive, wildcard, objectConstruct00, sourceFilePath);

            return objectConstruct00;
        }
Пример #19
0
        private static void ModelConstructors(ConstructorInfo[] constructorInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            ParameterInfo[] parameterInfos;

            if ((object)constructorInfos == null)
                throw new ArgumentNullException("constructorInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Constructors";
            parent.Items.Add(arrayConstruct00);

            foreach (ConstructorInfo constructorInfo in constructorInfos)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorName";
                propertyConstruct00.RawValue = constructorInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorCallingConvention";
                propertyConstruct00.RawValue = constructorInfo.CallingConvention;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorContainsGenericParameters";
                propertyConstruct00.RawValue = constructorInfo.ContainsGenericParameters;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsGenericMethod";
                propertyConstruct00.RawValue = constructorInfo.IsGenericMethod;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsGenericMethodDefinition";
                propertyConstruct00.RawValue = constructorInfo.IsGenericMethodDefinition;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsAbstract";
                propertyConstruct00.RawValue = constructorInfo.IsAbstract;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsAssembly";
                propertyConstruct00.RawValue = constructorInfo.IsAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsFamily";
                propertyConstruct00.RawValue = constructorInfo.IsFamily;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsFamilyAndAssembly";
                propertyConstruct00.RawValue = constructorInfo.IsFamilyAndAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsFamilyOrAssembly";
                propertyConstruct00.RawValue = constructorInfo.IsFamilyOrAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsFinal";
                propertyConstruct00.RawValue = constructorInfo.IsFinal;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsHideBySig";
                propertyConstruct00.RawValue = constructorInfo.IsHideBySig;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsPrivate";
                propertyConstruct00.RawValue = constructorInfo.IsPrivate;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsPublic";
                propertyConstruct00.RawValue = constructorInfo.IsPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsSecurityCritical";
                propertyConstruct00.RawValue = constructorInfo.IsSecurityCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsSecuritySafeCritical";
                propertyConstruct00.RawValue = constructorInfo.IsSecuritySafeCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsSecurityTransparent";
                propertyConstruct00.RawValue = constructorInfo.IsSecurityTransparent;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsSpecialName";
                propertyConstruct00.RawValue = constructorInfo.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsStatic";
                propertyConstruct00.RawValue = constructorInfo.IsStatic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorIsVirtual";
                propertyConstruct00.RawValue = constructorInfo.IsVirtual;
                objectConstruct00.Items.Add(propertyConstruct00);
            #if !__MonoCS__
                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ConstructorMethodImplementationFlags";
                propertyConstruct00.RawValue = constructorInfo.MethodImplementationFlags;
                objectConstruct00.Items.Add(propertyConstruct00);
            #endif
                ModelCustomAttributes(constructorInfo, objectConstruct00);

                parameterInfos = constructorInfo.GetParameters();

                ModelParameters(parameterInfos, objectConstruct00);
            }
        }
Пример #20
0
        private static void EnumerateFileSystem(string directoryPath, bool recursive, string wildcard, AssociativeXmlObject parent, string sourcePath)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            ArrayConstruct arrayConstruct01;
            PropertyConstruct propertyConstruct01;
            ObjectConstruct objectConstruct01;

            string[] directories;
            string[] files;

            if ((object)directoryPath == null)
                throw new ArgumentNullException("directoryPath");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Files";
            parent.Items.Add(arrayConstruct00);

            arrayConstruct01 = new ArrayConstruct();
            arrayConstruct01.Name = "Directories";
            parent.Items.Add(arrayConstruct01);

            if (File.Exists(directoryPath))
            {
                files = new string[] { Path.GetFullPath(directoryPath) };
                directories = null;
            }
            else
            {
                if (DataType.IsNullOrWhiteSpace(wildcard))
                    files = Directory.GetFiles(directoryPath);
                else
                    files = Directory.GetFiles(directoryPath, wildcard);

                if (DataType.IsNullOrWhiteSpace(wildcard))
                    directories = Directory.GetDirectories(directoryPath);
                else
                    directories = Directory.GetDirectories(directoryPath, wildcard);
            }

            if ((object)files != null)
            {
                foreach (string file in files)
                {
                    FileInfo fileInfo;

                    fileInfo = new FileInfo(file);

                    objectConstruct00 = new ObjectConstruct();
                    arrayConstruct00.Items.Add(objectConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileFullName";
                    propertyConstruct00.RawValue = fileInfo.FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileFullNameRelativeToSource";
                    propertyConstruct00.RawValue = EvaluateRelativePath2(sourcePath, fileInfo.FullName);
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileCreationTime";
                    propertyConstruct00.RawValue = fileInfo.CreationTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileCreationTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.CreationTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileExtension";
                    propertyConstruct00.RawValue = fileInfo.Extension;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileIsReadOnly";
                    propertyConstruct00.RawValue = fileInfo.IsReadOnly;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileLastAccessTime";
                    propertyConstruct00.RawValue = fileInfo.LastAccessTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileLastAccessTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.LastAccessTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileLastWriteTime";
                    propertyConstruct00.RawValue = fileInfo.LastWriteTime;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileLastWriteTimeUtc";
                    propertyConstruct00.RawValue = fileInfo.LastWriteTimeUtc;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileLength";
                    propertyConstruct00.RawValue = fileInfo.Length;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FileName";
                    propertyConstruct00.RawValue = fileInfo.Name;
                    objectConstruct00.Items.Add(propertyConstruct00);
                }
            }

            if ((object)directories != null)
            {
                foreach (string directory in directories)
                {
                    DirectoryInfo directoryInfo;

                    directoryInfo = new DirectoryInfo(directory);

                    objectConstruct01 = new ObjectConstruct();
                    arrayConstruct01.Items.Add(objectConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryFullName";
                    propertyConstruct01.RawValue = directoryInfo.FullName;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryFullNameRelativeToSource";
                    propertyConstruct01.RawValue = EvaluateRelativePath2(sourcePath, directoryInfo.FullName);
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryAttributes";
                    propertyConstruct01.RawValue = directoryInfo.Attributes;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryCreationTime";
                    propertyConstruct01.RawValue = directoryInfo.CreationTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryCreationTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.CreationTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryExtension";
                    propertyConstruct01.RawValue = directoryInfo.Extension;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryLastAccessTime";
                    propertyConstruct01.RawValue = directoryInfo.LastAccessTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryLastAccessTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.LastAccessTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryLastWriteTime";
                    propertyConstruct01.RawValue = directoryInfo.LastWriteTime;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryLastWriteTimeUtc";
                    propertyConstruct01.RawValue = directoryInfo.LastWriteTimeUtc;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    propertyConstruct01 = new PropertyConstruct();
                    propertyConstruct01.Name = "DirectoryName";
                    propertyConstruct01.RawValue = directoryInfo.Name;
                    objectConstruct01.Items.Add(propertyConstruct01);

                    if (recursive)
                        EnumerateFileSystem(directory, recursive, wildcard, objectConstruct01, sourcePath);
                }
            }
        }
Пример #21
0
        private static void ModelCustomAttributes(ICustomAttributeProvider customAttributeProvider, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;
            ArrayConstruct arrayConstruct01;
            ObjectConstruct objectConstruct01;
            PropertyConstruct propertyConstruct01;

            Attribute[] customAttributes;
            PropertyInfo[] publicPropertyInfos;
            object value;

            if ((object)customAttributeProvider == null)
                throw new ArgumentNullException("customAttributeProvider");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            customAttributes = Reflexion.GetAllAttributes<Attribute>(customAttributeProvider);

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "CustomAttributes";
            parent.Items.Add(arrayConstruct00);

            if ((object)customAttributes != null)
            {
                foreach (Attribute customAttribute in customAttributes)
                {
                    objectConstruct00 = new ObjectConstruct();
                    arrayConstruct00.Items.Add(objectConstruct00);

                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "CustomAttributeTypeFullName";
                    propertyConstruct00.RawValue = customAttribute.GetType().FullName;
                    objectConstruct00.Items.Add(propertyConstruct00);

                    publicPropertyInfos = customAttribute.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

                    if ((object)publicPropertyInfos != null)
                    {
                        arrayConstruct01 = new ArrayConstruct();
                        arrayConstruct01.Name = "CustomAttributeProperties";
                        objectConstruct00.Items.Add(arrayConstruct01);

                        foreach (PropertyInfo publicPropertyInfo in publicPropertyInfos)
                        {
                            objectConstruct01 = new ObjectConstruct();
                            arrayConstruct01.Items.Add(objectConstruct01);

                            propertyConstruct01 = new PropertyConstruct();
                            propertyConstruct01.Name = "CustomAttributePropertyName";
                            propertyConstruct01.RawValue = publicPropertyInfo.Name;
                            objectConstruct01.Items.Add(propertyConstruct01);

                            if (Reflexion.GetLogicalPropertyValue(customAttribute, publicPropertyInfo.Name, out value))
                            {
                                propertyConstruct01 = new PropertyConstruct();
                                propertyConstruct01.Name = "CustomAttributePropertyValue";
                                propertyConstruct01.RawValue = value.SafeToString();
                                objectConstruct01.Items.Add(propertyConstruct01);
                            }
                        }
                    }
                }
            }
        }
Пример #22
0
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary<string, IList<string>> properties)
        {
            const string PROP_TOKEN_FIRST_ROW_CONTAINS_COLUMN_HEADINGS = "FirstRowIsHeader";
            const string PROP_TOKEN_FIELD_DELIMITER = "FieldDelimiter";
            //const string PROP_TOKEN_ROW_DELIMITER = "RowDelimiter";
            string line;
            ObjectConstruct objectConstruct00;
            ArrayConstruct arrayConstruct00;
            IList<string> values;
            bool firstRowIsHeader = false;
            string firstRowIsHeaderStr;
            string fieldDelimiter;
            string[] headers = null;

            if ((object)sourceFilePath == null)
                throw new ArgumentNullException("sourceFilePath");

            if ((object)properties == null)
                throw new ArgumentNullException("properties");

            if (DataType.IsWhiteSpace(sourceFilePath))
                throw new ArgumentOutOfRangeException("sourceFilePath");

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();
            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "TextFileLines";
            objectConstruct00.Items.Add(arrayConstruct00);

            firstRowIsHeaderStr = null;
            if (properties.TryGetValue(PROP_TOKEN_FIRST_ROW_CONTAINS_COLUMN_HEADINGS, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    firstRowIsHeaderStr = values[0];
                    if (!DataType.TryParse<bool>(firstRowIsHeaderStr, out firstRowIsHeader))
                        firstRowIsHeader = false;
                }
            }

            fieldDelimiter = null;
            if (properties.TryGetValue(PROP_TOKEN_FIELD_DELIMITER, out values))
            {
                if ((object)values != null && values.Count == 1)
                    fieldDelimiter = values[0];
            }

            using (StreamReader streamReader = File.OpenText(sourceFilePath))
            {
                int i = 0;

                while (((line = streamReader.ReadLine()) ?? "").Trim() != "")
                {
                    ObjectConstruct objectConstruct01;
                    PropertyConstruct propertyConstruct01;
                    string[] temp;

                    objectConstruct01 = new ObjectConstruct();
                    arrayConstruct00.Items.Add(objectConstruct01);

                    if (DataType.IsNullOrWhiteSpace(fieldDelimiter))
                    {
                        propertyConstruct01 = new PropertyConstruct();
                        propertyConstruct01.Name = "TextFileLine";
                        propertyConstruct01.RawValue = line;
                        objectConstruct01.Items.Add(propertyConstruct01);
                    }
                    else
                    {
                        temp = line.Split(fieldDelimiter.ToCharArray());

                        if (firstRowIsHeader && i == 0)
                        {
                            headers = temp;
                            arrayConstruct00.Items.Remove(objectConstruct01);
                            i++;
                            continue;
                        }

                        if ((object)temp != null)
                        {
                            int j = 0;

                            foreach (string pmet in temp)
                            {
                                propertyConstruct01 = new PropertyConstruct();

                                if (firstRowIsHeader && (object)headers != null)
                                    propertyConstruct01.Name = string.Format("{0}", headers[j++]);
                                else
                                    propertyConstruct01.Name = string.Format("TextFileField_{0:00000000}", j++);

                                propertyConstruct01.RawValue = pmet;
                                objectConstruct01.Items.Add(propertyConstruct01);
                            }
                        }
                    }

                    i++;
                }
            }

            return objectConstruct00;
        }
Пример #23
0
        private static void ModelFields(FieldInfo[] fieldInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            if ((object)fieldInfos == null)
                throw new ArgumentNullException("fieldInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Fields";
            parent.Items.Add(arrayConstruct00);

            foreach (FieldInfo fieldInfo in fieldInfos)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldName";
                propertyConstruct00.RawValue = fieldInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldTypeName";
                propertyConstruct00.RawValue = fieldInfo.FieldType.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldTypeNamespace";
                propertyConstruct00.RawValue = fieldInfo.FieldType.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldTypeFullName";
                propertyConstruct00.RawValue = fieldInfo.FieldType.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldTypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = fieldInfo.FieldType.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsAssembly";
                propertyConstruct00.RawValue = fieldInfo.IsAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsFamily";
                propertyConstruct00.RawValue = fieldInfo.IsFamily;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsFamilyAndAssembly";
                propertyConstruct00.RawValue = fieldInfo.IsFamilyAndAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsFamilyOrAssembly";
                propertyConstruct00.RawValue = fieldInfo.IsFamilyOrAssembly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsInitOnly";
                propertyConstruct00.RawValue = fieldInfo.IsInitOnly;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsLiteral";
                propertyConstruct00.RawValue = fieldInfo.IsLiteral;
                objectConstruct00.Items.Add(propertyConstruct00);

                if (fieldInfo.IsLiteral)
                {
                    propertyConstruct00 = new PropertyConstruct();
                    propertyConstruct00.Name = "FieldRawConstantValue";
                    propertyConstruct00.RawValue = fieldInfo.GetRawConstantValue();
                    objectConstruct00.Items.Add(propertyConstruct00);
                }

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsNotSerialized";
                propertyConstruct00.RawValue = fieldInfo.IsNotSerialized;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsPinvokeImpl";
                propertyConstruct00.RawValue = fieldInfo.IsPinvokeImpl;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsPrivate";
                propertyConstruct00.RawValue = fieldInfo.IsPrivate;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsPublic";
                propertyConstruct00.RawValue = fieldInfo.IsPublic;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsSecurityCritical";
                propertyConstruct00.RawValue = fieldInfo.IsSecurityCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsSecuritySafeCritical";
                propertyConstruct00.RawValue = fieldInfo.IsSecuritySafeCritical;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsSecurityTransparent";
                propertyConstruct00.RawValue = fieldInfo.IsSecurityTransparent;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsSpecialName";
                propertyConstruct00.RawValue = fieldInfo.IsSpecialName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "FieldIsStatic";
                propertyConstruct00.RawValue = fieldInfo.IsStatic;
                objectConstruct00.Items.Add(propertyConstruct00);

                ModelCustomAttributes(fieldInfo, objectConstruct00);
            }
        }
        protected override object CoreGetSourceObject(string sourceFilePath, IDictionary <string, IList <string> > properties)
        {
            const string   PROP_TOKEN_CONNECTION_AQTN   = "ConnectionType";
            const string   PROP_TOKEN_CONNECTION_STRING = "ConnectionString";
            const string   PROP_TOKEN_GET_SCHEMA_ONLY   = "GetSchemaOnly";
            string         connectionAqtn;
            Type           connectionType   = null;
            string         connectionString = null;
            bool           getSchemaOnly    = false;
            IList <string> values;

            ObjectConstruct objectConstruct00;
            SqlQuery        sqlQuery;

            if ((object)sourceFilePath == null)
            {
                throw new ArgumentNullException(nameof(sourceFilePath));
            }

            if ((object)properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath))
            {
                throw new ArgumentOutOfRangeException(nameof(sourceFilePath));
            }

            connectionAqtn = null;
            if (properties.TryGetValue(PROP_TOKEN_CONNECTION_AQTN, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    connectionAqtn = values[0];
                    connectionType = Type.GetType(connectionAqtn, false);
                }
            }

            if ((object)connectionType == null)
            {
                throw new InvalidOperationException(string.Format("Failed to load the connection type '{0}' via Type.GetType(..).", connectionAqtn));
            }

            if (!typeof(DbConnection).IsAssignableFrom(connectionType))
            {
                throw new InvalidOperationException(string.Format("The connection type is not assignable to type '{0}'.", typeof(DbConnection).FullName));
            }

            if (properties.TryGetValue(PROP_TOKEN_CONNECTION_STRING, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    connectionString = values[0];
                }
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(connectionString))
            {
                throw new InvalidOperationException(string.Format("The connection string cannot be null or whitespace."));
            }

            if (properties.TryGetValue(PROP_TOKEN_GET_SCHEMA_ONLY, out values))
            {
                if ((object)values != null && values.Count == 1)
                {
                    SolderFascadeAccessor.DataTypeFascade.TryParse <bool>(values[0], out getSchemaOnly);
                }
            }

            sourceFilePath = Path.GetFullPath(sourceFilePath);

            sqlQuery = XmlSerializationStrategy.Instance.GetObjectFromFile <SqlQuery>(sourceFilePath);

            objectConstruct00 = new ObjectConstruct();

            WriteSqlQuery(new SqlQuery[] { sqlQuery }, objectConstruct00, connectionType, connectionString, getSchemaOnly);

            return(objectConstruct00);
        }
Пример #25
0
        private static void ModelParameters(ParameterInfo[] parameterInfos, AssociativeXmlObject parent)
        {
            ArrayConstruct arrayConstruct00;
            PropertyConstruct propertyConstruct00;
            ObjectConstruct objectConstruct00;

            if ((object)parameterInfos == null)
                throw new ArgumentNullException("parameterInfos");

            if ((object)parent == null)
                throw new ArgumentNullException("parent");

            arrayConstruct00 = new ArrayConstruct();
            arrayConstruct00.Name = "Parameters";
            parent.Items.Add(arrayConstruct00);

            foreach (ParameterInfo parameterInfo in parameterInfos)
            {
                objectConstruct00 = new ObjectConstruct();
                arrayConstruct00.Items.Add(objectConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterName";
                propertyConstruct00.RawValue = parameterInfo.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterDefaultValue";
                propertyConstruct00.RawValue = parameterInfo.DefaultValue;
                objectConstruct00.Items.Add(propertyConstruct00);
            #if !__MonoCS__
                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterHasDefaultValue";
                propertyConstruct00.RawValue = parameterInfo.HasDefaultValue;
                objectConstruct00.Items.Add(propertyConstruct00);
            #endif
                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsIn";
                propertyConstruct00.RawValue = parameterInfo.IsIn;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsLcid";
                propertyConstruct00.RawValue = parameterInfo.IsLcid;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsOptional";
                propertyConstruct00.RawValue = parameterInfo.IsOptional;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsOut";
                propertyConstruct00.RawValue = parameterInfo.IsOut;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsRetval";
                propertyConstruct00.RawValue = parameterInfo.IsRetval;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterTypeName";
                propertyConstruct00.RawValue = parameterInfo.ParameterType.Name;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterTypeNamespace";
                propertyConstruct00.RawValue = parameterInfo.ParameterType.Namespace;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterTypeFullName";
                propertyConstruct00.RawValue = parameterInfo.ParameterType.FullName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterTypeAssemblyQualifiedName";
                propertyConstruct00.RawValue = parameterInfo.ParameterType.AssemblyQualifiedName;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterIsByRef";
                propertyConstruct00.RawValue = parameterInfo.ParameterType.IsByRef;
                objectConstruct00.Items.Add(propertyConstruct00);

                propertyConstruct00 = new PropertyConstruct();
                propertyConstruct00.Name = "ParameterPosition";
                propertyConstruct00.RawValue = parameterInfo.Position;
                objectConstruct00.Items.Add(propertyConstruct00);

                ModelCustomAttributes(parameterInfo, objectConstruct00);
            }
        }
        private static void WriteSqlQuery(IEnumerable <SqlQuery> sqlQueries, IAssociativeXmlObject parentAssociativeXmlObject, Type connectionType, string connectionString, bool getSchemaOnly)
        {
            ArrayConstruct    arrayConstruct;
            ObjectConstruct   objectConstruct;
            PropertyConstruct propertyConstructA, propertyConstructB;
            Tokenizer         tokenizer;

            IEnumerable <IDictionary <string, object> > records;
            string commandText_;
            int    count = 0;

            if ((object)sqlQueries == null)
            {
                throw new ArgumentNullException(nameof(sqlQueries));
            }

            if ((object)parentAssociativeXmlObject == null)
            {
                throw new ArgumentNullException(nameof(parentAssociativeXmlObject));
            }

            if ((object)connectionType == null)
            {
                throw new ArgumentNullException(nameof(connectionType));
            }

            if ((object)connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(connectionString))
            {
                throw new ArgumentOutOfRangeException(nameof(connectionString));
            }

            tokenizer = new Tokenizer(true);

            foreach (SqlQuery sqlQuery in sqlQueries.OrderBy(c => c.Key).ThenBy(c => c.Order))
            {
                arrayConstruct      = new ArrayConstruct();
                arrayConstruct.Name = sqlQuery.Key;
                parentAssociativeXmlObject.Items.Add(arrayConstruct);

                commandText_ = tokenizer.ExpandTokens(sqlQuery.Text, new DynamicWildcardTokenReplacementStrategy(new object[] { parentAssociativeXmlObject }));

                // one hell of a polyfill ;)
                Func <CommandType, string, IEnumerable <DbParameter>, Action <long>, IEnumerable <__Record> > executeRecordsCallback =
                    (CommandType commandType, string commandText, IEnumerable <DbParameter> dbParameters, Action <long> resultCallback) =>
                {
                    const bool           _schemaOnly       = false;
                    Type                 _connectionType   = connectionType;
                    string               _connectionString = connectionString;
                    const bool           _transactional    = false;
                    const IsolationLevel _isolationLevel   = IsolationLevel.Unspecified;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.ExecuteRecords(_schemaOnly, _connectionType, _connectionString, _transactional, _isolationLevel, commandType, commandText, dbParameters, resultCallback));
                };

                Func <CommandType, string, IEnumerable <DbParameter>, Action <long>, IEnumerable <__Record> > executeSchemaRecordsCallback =
                    (CommandType commandType, string commandText, IEnumerable <DbParameter> dbParameters, Action <long> resultCallback) =>
                {
                    const bool           _schemaOnly       = true;
                    Type                 _connectionType   = connectionType;
                    string               _connectionString = connectionString;
                    const bool           _transactional    = false;
                    const IsolationLevel _isolationLevel   = IsolationLevel.Unspecified;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.ExecuteRecords(_schemaOnly, _connectionType, _connectionString, _transactional, _isolationLevel, commandType, commandText, dbParameters, resultCallback));
                };

                Func <string, ParameterDirection, DbType, int, byte, byte, bool, string, object, DbParameter> createParameterCallback =
                    (string sourceColumn, ParameterDirection parameterDirection, DbType parameterDbType, int parameterSize, byte parameterPrecision, byte parameterScale, bool parameterNullable, string parameterName, object parameterValue) =>
                {
                    Type _connectionType = connectionType;

                    return(SolderFascadeAccessor.AdoNetBufferingFascade.CreateParameter(_connectionType, sourceColumn, parameterDirection, parameterDbType, parameterSize, parameterPrecision, parameterScale, parameterNullable, parameterName, parameterValue));
                };

                var unitOfWork = new
                {
                    ExecuteRecords       = executeRecordsCallback,
                    ExecuteSchemaRecords = executeSchemaRecordsCallback,
                    CreateParameter      = createParameterCallback
                };

                // using (null)
                {
                    if (getSchemaOnly)
                    {
                        records = unitOfWork.ExecuteRecords(sqlQuery.Type, commandText_, new DbParameter[] { }, null);
                    }
                    else
                    {
                        records = unitOfWork.ExecuteSchemaRecords(sqlQuery.Type, commandText_, new DbParameter[] { }, null);
                    }

                    records = records.ToArray();                     // force eager load
                }

                propertyConstructA      = new PropertyConstruct();
                propertyConstructA.Name = "RowCount";
                arrayConstruct.Items.Add(propertyConstructA);

                if ((object)records != null)
                {
                    foreach (IDictionary <string, object> record in records)
                    {
                        objectConstruct = new ObjectConstruct();
                        arrayConstruct.Items.Add(objectConstruct);

                        if ((object)record != null)
                        {
                            foreach (KeyValuePair <string, object> keyValuePair in record)
                            {
                                propertyConstructB          = new PropertyConstruct();
                                propertyConstructB.Name     = keyValuePair.Key;
                                propertyConstructB.RawValue = keyValuePair.Value;

                                objectConstruct.Items.Add(propertyConstructB);
                            }
                        }

                        // correlated
                        WriteSqlQuery(sqlQuery.SubQueries, objectConstruct, connectionType, connectionString, getSchemaOnly);

                        count++;
                    }

                    propertyConstructA.RawValue = count;
                }
            }
        }