예제 #1
0
        /// <summary>
        /// Process embedded resources.
        /// </summary>
        private void ProcessEmbeddedResource()
        {
            string[] embeddedResources = Assembly.GetAssembly(typeof(IWizardImplementation)).GetManifestResourceNames();
            var      assembly          = Assembly.GetExecutingAssembly();

            // Build the string of resources.
            foreach (string resource in embeddedResources)
            {
                //PDebug(GetCurrentMethod());
                using (Stream stream = assembly.GetManifestResourceStream(resource))
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string bentleyApp = BentleyApp;
                        string result     = "";
                        if (bentleyApp.Contains("OpenRoads") || bentleyApp.Contains("OpenRail"))
                        {
                            if (resource.Contains("{F7AD6FF5-34E0-4FBE-B5CF}"))
                            {
                                result = GetSubstituteResult("innovoCAD.Bentley.CONNECT.EmbeddedResources.MicroStationUtilities.{F7AD6FF5-34E0-4FBE-ORD}.cpp");
                            }
                            else if (resource.Contains("{FAD22EAD-82A1-4DB6-9718-B91226D9A42A}"))
                            {
                                result = GetSubstituteResult("innovoCAD.Bentley.CONNECT.EmbeddedResources.native.{FAD22EAD-82A1-4DB6-9718-B91226D9-ORD}.h");
                            }
                            //else
                            //    result = reader.ReadToEnd();
                        }
                        else
                        {
                            if (resource.Contains("{F7AD6FF5-34E0-4FBE-B5CF}"))
                            {
                                result = GetSubstituteResult("innovoCAD.Bentley.CONNECT.EmbeddedResources.MicroStationUtilities.{F7AD6FF5-34E0-4FBE-B5CF}.cpp");
                            }
                            else if (resource.Contains("{FAD22EAD-82A1-4DB6-9718-B91226D9A42A}"))
                            {
                                result = GetSubstituteResult("innovoCAD.Bentley.CONNECT.EmbeddedResources.native.{FAD22EAD-82A1-4DB6-9718-B91226D9A42A}.h");
                            }
                        }
                        //result = reader.ReadToEnd();

                        string[] resourceItemCollection = resource.Split('.');
                        foreach (var resourceItem in resourceItemCollection)
                        {
                            if (resourceItem.Contains("{"))
                            {
                                if (!ReplacementsDictionary.ContainsKey("$" + resourceItem + "$"))
                                {
                                    ReplacementsDictionary.Add("$" + resourceItem + "$", result);
                                }
                            }
                        }
                    }
            }
        }
예제 #2
0
        /// <summary>
        /// Process project.
        /// </summary>
        private void ProcessProject()
        {
            if (ProjectFileInfo.Name == "MSCE.Keyin.vstemplate" || ProjectFileInfo.Name == "MSCE.Addin.vstemplate")
            {
                ProcessEmbeddedResource();
            }

            ReplacementsDictionary.Add("$ToolVersion$", Version);
            ReplacementsDictionary.Add("$platformtoolset$", PlatFormToolSet);
            ReplacementsDictionary.Add("$AddinAttribute$", AddAddinAttribute());
            ReplacementsDictionary.Add("$reference$", AddReferences());
        }
        /// <summary>
        /// Adds to replacements dictionary name-value pairs from all public properties from given data which has PfeColumnAttribute.
        /// The path should be specified in case of nested data (by dependency relation) - and defines the 'prefix' (which is then appended by '/' char inside)
        /// </summary>
        public static void FillDictionaryFromObjectByProperties(ReplacementsDictionary replacements, object data, string path = null)
        {
            //standardize path
            path = path == null ? "" : path + ".";

            foreach (var propertyInfo in data.GetType().GetProperties())
            {
                object ovalue = propertyInfo.GetValue(data);
                string format = null;
                string name   = path + propertyInfo.Name;

                replacements.Add(name, ovalue, format);
            }
        }
        /// <summary>
        /// Adds to replacements dictionary name-value pairs from all public properties from given data which has PfeColumnAttribute.
        /// The path should be specified in case of nested data (by dependency relation) - and defines the 'prefix' (which is then appended by '/' char inside)
        /// </summary>
        public static void FillDictionaryFromObject(ReplacementsDictionary replacements, object data, string path = null)
        {
            //standardize path
            path = path == null ? "" : path + ".";

            var props = (from p in data.GetType().GetProperties()
                         let attr = p.GetCustomAttributes(typeof(PfeColumnAttribute), true)
                                    where attr.Length == 1
                                    select new { Property = p, Attribute = attr.First() as PfeColumnAttribute }).ToList();

            foreach (var item in props)
            {
                object ovalue = item.Property.GetValue(data);

                string format = null;
                if (ovalue != null)
                {
                    if (item.Attribute.Type == PfeDataType.Date)
                    {
                        format = "D"; //date
                    }
                    else if (item.Attribute.Type == PfeDataType.DateTime)
                    {
                        format = "DT"; //date and time
                    }
                    else if (item.Attribute.Type == PfeDataType.Time)
                    {
                        format = "T"; //time
                    }
                    else if (ovalue is decimal)
                    {
                        switch (item.Attribute.DecimalPlaces)
                        {
                        case 0:
                            format = "N0";
                            break;

                        case 1:
                            format = "N1";
                            break;

                        case 2:
                            format = "N2";
                            break;

                        case 3:
                            format = "N3";
                            break;

                        case 4:
                            format = "N4";
                            break;

                        case 5:
                            format = "N5";
                            break;
                        }
                    }
                }

                string name = path + (item.Attribute.Text ?? item.Property.Name);
                replacements.Add(name, ovalue, format);
            }
        }