예제 #1
0
파일: Topology.cs 프로젝트: pulsence/ENN
 /// <summary>
 /// Helper method that writes meta data to disk.
 /// </summary>
 /// <param name="writer">Reference to the StreamWriter that is being used
 /// to write to disk</param>
 /// <param name="metaData">The object whoes meta data should be writen to disk</param>
 /// <exception cref="IOException">System.IO.IOException</exception>
 private static void WriteMeta(ref StreamWriter writer, IMetaData metaData)
 {
     foreach (KeyValuePair <string, string> el in metaData.MetaData)
     {
         writer.WriteLine("\t{0}:{1}", el.Key, el.Value);
     }
 }
예제 #2
0
        static IImageStream CreateMetaDataStream(IMetaData metaData)
        {
            var peImage   = metaData.PEImage;
            var mdDataDir = metaData.ImageCor20Header.MetaData;

            return(peImage.CreateStream(mdDataDir.VirtualAddress, mdDataDir.Size));
        }
예제 #3
0
		public Schema(string factory, IDbConnection con)
		{
			switch(factory) {
			// TODO: load from XML config file instead hard-coding
			case "System.Data.OracleClient":
				metaData = new OracleMetaData(con);
				break;
			case "System.Data.SqlClient":
				metaData = new SqlMetaData(con);
				break;
			case "ByteFX.Data.MySqlClient":
			case "MySql.Data":
				metaData = new MySqlMetaData(con);
				break;
			case "Npgsql":
				metaData = new PostgreSqlMetaData(con);
				break;
			case "FirebirdSql.Data.Firebird":
				metaData = new FirebirdMetaData(con);
				break;
			case "Mono.Data.SybaseClient":
				metaData = new SybaseMetaData(con);
				break;
			case "Mono.Data.SqliteClient":
				metaData = new SqliteMetaData(con);
				break;
			default:
				break;
			}
		}
예제 #4
0
 public override ICalculateOutput Calc(ICalculateInpute input)
 {
     if (input.DataSource.Any())
     {
         double    result = input.DataSource.Min(t => double.Parse(t.TagValue));
         IMetaData md     = input.DataSource.First();
         return(new CalculateOutput(input.SessinId, DateTime.Now,
                                    new MetaData[] {
             new MetaData()
             {
                 TagTime = input.InputeDateTime,
                 TagValue = result.ToString(),
                 TagId = ResultId,
                 TagName = md.TagName,
                 Code = md.Code,
                 WindowId = md.WindowId,
                 ExtValue = md.ExtValue
             }
         }));
     }
     else
     {
         return(null);
     }
 }
예제 #5
0
    protected void btnBak_Click(object sender, EventArgs e)
    {
        String bak = txtBak.Text;

        if (String.IsNullOrEmpty(bak))
        {
            return;
        }

        DAL dal = GetDAL();

        if (dal.DbType != DatabaseType.SQLite)
        {
            WebHelper.Alert("仅支持SQLite备份!");
            return;
        }

        try
        {
            IMetaData md = dal.Db.CreateMetaData();
            Reflect.Invoke(md, "Backup", bak);

            WebHelper.Alert("完成!");
        }
        catch (Exception ex)
        {
            WebHelper.Alert(ex.ToString());
        }
    }
예제 #6
0
파일: Mode.cs 프로젝트: yuzs/CSharpFlink
 public override ICalculateOutput Calc(ICalculateInpute input)
 {
     if (input.DataSource.Any())
     {
         var source  = input.DataSource.Select(t => t.tag_value).ToList();
         var modeSor = from item in source
                       group item by item into gro
                       orderby gro.Count() descending
                       select new { num = gro.Key, nums = gro.Count() };
         double.TryParse(modeSor.FirstOrDefault().num, out double result);
         IMetaData md = input.DataSource.First();
         return(new CalculateOutput(input.SessinId, DateTime.Now,
                                    new MetaData[] {
             new MetaData()
             {
                 tag_time = input.InputeDateTime,
                 tag_value = result.ToString(),
                 tag_id = md.tag_id,
                 tag_name = md.tag_name,
                 code = md.code,
                 window_id = md.window_id,
                 ext_value = md.ext_value
             }
         }));
     }
     else
     {
         return(null);
     }
 }
        public override void Run(object context)
        {
            while (_isRun)
            {
                try
                {
                    SourceContext sc = (SourceContext)context;
                    for (int i = 0; i < Program.TaskCount; i++)
                    {
                        string key = i.ToString("0000");

                        IMetaData md = Calc.GetMetaData(key, TestCommon.DataType.RtData, _delayWindowCount, _windowInterval);

                        sc.Collect((new IMetaData[] { md }).ToArray());
                    }
                }
                catch (ThreadInterruptedException ex)
                {
                    Logger.Log.Error(true, "RandomSourceFunction:", ex);
                    break;
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(true, "RandomSourceFunction:", ex);
                }

                Thread.Sleep(Interval);
            }
        }
예제 #8
0
        public override ICalculateOutput Calc(ICalculateInpute input)
        {
            if (input.DataSource.Any())
            {
                string   script          = input.Script;
                string[] patternDataList = ExpressionTask.GetPatternDataList(script);
                foreach (string pattern in patternDataList)
                {
                    IMetaData md = input.DataSource.FirstOrDefault(t => t.TagId == pattern);

                    if (md != null)
                    {
                        script = script.Replace($"[{pattern}]", md.TagValue.ToString());
                    }
                }

                object result = CSharpScript.EvaluateAsync(script).Result;

                return(new CalculateOutput(input.SessinId, DateTime.Now,
                                           new MetaData[] {
                    new MetaData()
                    {
                        TagId = ResultId,
                        TagTime = input.InputeDateTime,
                        TagValue = result.ToString()
                    }
                }));
            }
            else
            {
                return(null);
            }
        }
예제 #9
0
    public void UpdateTimestamp(uint _dateIndex)
    {
        m_CurrentData = Singleton.GetDataManager().MetaData;

        if (m_CurrentData != null)
        {
            if (Singleton.GetDataManager().CurrentVariableName != null)
            {
                CurrentIndex = _dateIndex;

                try
                {
                    VarDateFloat = m_CurrentData.Timestamps[0][( int )_dateIndex].DateTimeDouble;
                }
                catch (Exception e)
                {
                    Log.Warn(this, "the timestamp " + _dateIndex.ToString() + " could not be updated: " + e);
                }

                DateTimeString = Utils.TryConvertDoubleToDateTimeString(VarDateFloat);

                CurrentDate = Singleton.GetDataManager().CurrentVariableName + "_" + DateTimeString;
                this.GetTimestampLabel().text = Singleton.GetDataManager().CurrentVariableName + "\n" + DateTimeString;
            }
            else
            {
                Log.Info(this, "No data to show in label, current variable is null.");
            }
        }
        else
        {
            Log.Info(this, "No data to show in label, current data is null.");
        }
    }
예제 #10
0
        public static List <TemplateData> Build(Dictionary <string, Model> models,
                                                Dictionary <string, List <String> > generationObjects, GenerationSettings settings)
        {
            List <TemplateData> templateDatas = new List <TemplateData>();

            foreach (var genObject in generationObjects)
            {
                foreach (string objId in genObject.Value)
                {
                    IMetaData modelObject = GetModelObject(models[genObject.Key], objId);
                    if (modelObject == null)
                    {
                        continue;
                    }

                    foreach (string templateName in settings.TemplatesNames)
                    {
                        TemplateData templateData = Build(modelObject, settings, templateName,
                                                          models[genObject.Key].Database, genObject.Key);
                        if (templateData != null)
                        {
                            templateDatas.Add(templateData);
                        }
                    }
                }
            }

            return(templateDatas);
        }
예제 #11
0
 public virtual void ProcessAttributes(IMetaData metaData, ICustomAttributeProvider attributeProvider)
 {
     foreach(AttributeProcessor processor in AttributeProcessors)
     {
         processor.Process(metaData, attributeProvider, this.Config);
     }
 }
예제 #12
0
 public override ICalculateOutput Calc(ICalculateInpute input)
 {
     if (input.DataSource.Any())
     {
         var source  = input.DataSource.Select(t => t.TagValue).ToList();
         var modeSor = from item in source
                       group item by item into gro
                       orderby gro.Count() descending
                       select new { num = gro.Key, nums = gro.Count() };
         double.TryParse(modeSor.FirstOrDefault().num, out double result);
         IMetaData md = input.DataSource.First();
         return(new CalculateOutput(input.SessinId, DateTime.Now,
                                    new MetaData[] {
             new MetaData()
             {
                 TagTime = input.InputeDateTime,
                 TagValue = result.ToString(),
                 TagId = ResultId,
                 TagName = md.TagName,
                 Code = md.Code,
                 WindowId = md.WindowId,
                 ExtValue = md.ExtValue
             }
         }));
     }
     else
     {
         return(null);
     }
 }
예제 #13
0
        public override void RegisterMetaData(IMetaData[] metadata)
        {
            base.RegisterMetaData(metadata);

            if (_Delegator != null)
                _Delegator.RegisterMetaData(metadata);
        }
예제 #14
0
        static void TestMasterNode()
        {
            Console.WriteLine("请输入任务数:");

            _initTagNum = int.Parse(Console.ReadLine());

            while (true)
            {
                for (int i = 0; i < _initTagNum; i++)
                {
                    string key = i.ToString("0000");
                    if (!execution.TaskManager.ContainsWindow(key))
                    {
                        _windowInterval = Calc.GetRandomWindowInterval();
                        _calculate      = Calc.GetAggRandomCalculate();

                        execution.TaskManager.AddWindowTask(key, $"窗口{key}", _windowInterval, _delayWindowCount, _calculate);

                        IMetaData md = Calc.GetMetaData(key, TestCommon.DataType.RtData, _delayWindowCount, _windowInterval);

                        execution.TaskManager.AddMetaData(key, md);
                    }
                    else
                    {
                        IMetaData md = Calc.GetMetaData(key, TestCommon.DataType.RtData, _delayWindowCount, _windowInterval);
                        execution.TaskManager.AddMetaData(key, md);
                    }
                }
                Thread.Sleep(1000);
            }
        }
예제 #15
0
        /// <summary>
        /// Writes the graphics control extension to the stream.
        /// </summary>
        /// <param name="metaData">The metadata of the image or frame.</param>
        /// <param name="writer">The stream to write to.</param>
        /// <param name="transparencyIndex">The index of the color in the color palette to make transparent.</param>
        private void WriteGraphicalControlExtension(IMetaData metaData, EndianBinaryWriter writer, int transparencyIndex)
        {
            var extension = new GifGraphicsControlExtension
            {
                DisposalMethod    = metaData.DisposalMethod,
                TransparencyFlag  = transparencyIndex > -1,
                TransparencyIndex = unchecked ((byte)transparencyIndex),
                DelayTime         = metaData.FrameDelay
            };

            // Write the intro.
            this.buffer[0] = GifConstants.ExtensionIntroducer;
            this.buffer[1] = GifConstants.GraphicControlLabel;
            this.buffer[2] = 4;
            writer.Write(this.buffer, 0, 3);

            var field = default(PackedField);

            field.SetBits(3, 3, (int)extension.DisposalMethod); // 1-3 : Reserved, 4-6 : Disposal

            // TODO: Allow this as an option.
            field.SetBit(6, false);                      // 7 : User input - 0 = none
            field.SetBit(7, extension.TransparencyFlag); // 8: Has transparent.

            writer.Write(field.Byte);
            writer.Write((ushort)extension.DelayTime);
            writer.Write(extension.TransparencyIndex);
            writer.Write(GifConstants.Terminator);
        }
        public async Task Run(IRunInfo runInfo, IMetaData metaData)
        {
            try
            {
                Logger?.Write(LogLevels.Information, $"{Name} Started");
                MetaData = metaData;
                RunInfo  = await Initialize(runInfo);
                await BuildInitialStages();

                if (runInfo.Type != RunType.Build)
                {
                    await RunStage(StagePath.Root, GetStage(StagePath.Root));
                }
                Logger?.Write(LogLevels.Information, $"{Name} Finished");
            }
            catch (OperationCanceledException)
            {
                Logger?.Write(LogLevels.Warning, $"{Name} Cancelled");
            }
            catch (Exception ex)
            {
                Logger?.Write(LogLevels.Fatal, $"{Name} threw an exception");
                Logger?.Write(LogLevels.Fatal, ex);
            }
            finally
            {
                await RunFinally();
            }
        }
예제 #17
0
		public MDTableModel(MDTableHeapModel parent, IMetaData metadata, TablesStream stream, MDTable table) {
			Parent = parent;
			MetaData = metadata;
			Tables = stream;
			MDTable = table;
			Text = string.Format("{0:x2}: {1} (0x{2:x})", (byte)table.Table, table.Name, table.Rows);
		}
예제 #18
0
    public static DependencyProperty DependencyProperty <TSource, TValue>(
        this IMetaData <TSource> factory,
        Expression <Func <TSource, TValue> > instancePropertyExpression,
        Action <TSource, TValue, TValue>?onValueChanged = null, TValue defaultValue = default(TValue),
        FrameworkPropertyMetadataOptions options        = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, [CallerMemberName] string fieldName = default !)
    {
        PropertyMetadata metadata;

        if (onValueChanged == null)
        {
            metadata = new FrameworkPropertyMetadata(defaultValue, options);
        }
        else
        {
            metadata = new FrameworkPropertyMetadata(
                defaultValue, options, (o, args) => onValueChanged(
                    (TSource)(object)o, (TValue)args.OldValue, (TValue)args.NewValue));
        }

        var instancePropertyName = fieldName.Substring(0, fieldName.Length - "Property".Length);

        var dependencyProperty = System.Windows.DependencyProperty.Register(
            instancePropertyName, typeof(TValue), typeof(TSource), metadata);

        return(dependencyProperty);
    }
예제 #19
0
        internal static dynamic GetNewViewBag(IPageData page, IMetaData metaData,
                                              UserScript script, object pageData)
        {
            dynamic viewBag = new ExpandoObject();

            viewBag.Title = page.Title;
            if (metaData != null)
            {
                viewBag.MetaData = metaData;
                string title = metaData.Title;
                if (!string.IsNullOrEmpty(title))
                {
                    viewBag.Title = title;
                }
            }
            if (script != null)
            {
                viewBag.Script = script;
            }
            if (pageData != null)
            {
                viewBag.PageData = pageData;
            }

            return(viewBag);
        }
예제 #20
0
        DmdEcma335MetadataReader(DmdModuleImpl module, IMetaData metadata)
        {
            signatureLock        = new object();
            this.module          = module;
            Metadata             = metadata;
            fieldTypeCache       = new Dictionary <uint, DmdType>();
            methodSignatureCache = new Dictionary <uint, DmdMethodSignature>();

            var row = TablesStream.ReadModuleRow(1);

            ModuleScopeName = metadata.StringsStream.ReadNoNull(row?.Name ?? 0);
            ModuleVersionId = metadata.GuidStream.Read(row?.Mvid ?? 0) ?? Guid.Empty;

            var ts = TablesStream;

            typeRefList      = new LazyList <DmdTypeRef>(ts.TypeRefTable.Rows, rid => new DmdTypeRefMD(this, rid, null));
            fieldList        = new LazyList <DmdFieldDef, DmdTypeDef>(ts.FieldTable.Rows, CreateResolvedField);
            typeDefList      = new LazyList <DmdTypeDef>(ts.TypeDefTable.Rows, rid => new DmdTypeDefMD(this, rid, null));
            methodList       = new LazyList <DmdMethodBase, DmdTypeDef>(ts.MethodTable.Rows, CreateResolvedMethod);
            memberRefList    = new LazyList2 <DmdMemberInfo, IList <DmdType>, IList <DmdType> >(ts.MemberRefTable.Rows, CreateResolvedMemberRef);
            eventList        = new LazyList <DmdEventDef, DmdTypeDef>(ts.EventTable.Rows, CreateResolvedEvent);
            propertyList     = new LazyList <DmdPropertyDef, DmdTypeDef>(ts.PropertyTable.Rows, CreateResolvedProperty);
            typeSpecList     = new LazyList2 <DmdType, IList <DmdType>, IList <DmdType> >(ts.TypeSpecTable.Rows, ReadTypeSpec);
            exportedTypeList = new LazyList <DmdTypeRef>(ts.ExportedTypeTable.Rows, rid => new DmdExportedTypeMD(this, rid, null));

            globalTypeIfThereAreNoTypes = new DmdNullGlobalType(module, null);
        }
예제 #21
0
 protected override TranscodeFormatTuple?GetFormat(
     IMetaData meta,
     ILevelInfo li
     )
 {
     return(new TranscodeFormatTuple(this.graphicsFormat, this.transF));
 }
 /// <summary>
 /// Sets the frame delay in the metadata.
 /// </summary>
 /// <param name="metaData">The meta data.</param>
 private void SetFrameDelay(IMetaData metaData)
 {
     if (this.graphicsControlExtension != null && this.graphicsControlExtension.DelayTime > 0)
     {
         metaData.FrameDelay = this.graphicsControlExtension.DelayTime;
     }
 }
예제 #23
0
파일: DiskStore.cs 프로젝트: JabX/kinetix
        /// <summary>
        /// Find a "relatively" unused disk element, but not the element just added.
        /// </summary>
        /// <returns>DiskElement.</returns>
        private DiskElement FindRelativelyUnused()
        {
            IMetaData[] elements = DiskStore.SampleElements(_diskElements);
            IMetaData   element  = LfuPolicy.LeastHit(elements, null);

            return((DiskElement)element);
        }
예제 #24
0
 public void SetMetaData(IPageStyle style, IMetaData metaData)
 {
     if (UseXsltArgs)
     {
         fMetaData = metaData;
     }
 }
예제 #25
0
        public override ICalculateOutput Calc(ICalculateInpute input)
        {
            if (input.DataSource.Any())
            {
                double result = input.DataSource.Average(t => double.Parse(t.tag_value));

                IMetaData md = input.DataSource.First();

                return(new CalculateOutput(input.SessinId, DateTime.Now,
                                           new MetaData[] {
                    new MetaData()
                    {
                        tag_time = input.InputeDateTime,
                        tag_value = result.ToString(),
                        tag_id = md.tag_id,
                        tag_name = md.tag_name,
                        code = md.code,
                        window_id = md.window_id,
                        ext_value = md.ext_value
                    }
                }));
            }
            else
            {
                return(null);
            }
        }
        public static TranscodeFormatTuple?GetFormatsForImage(
            IMetaData meta,
            ILevelInfo li,
            bool linear = false
            )
        {
            TranscodeFormatTuple?formats;

            formats = TranscodeFormatHelper.GetPreferredFormat(
                meta.hasAlpha,
                li.isPowerOfTwo,
                li.isSquare,
                linear
                );

            if (!formats.HasValue && meta.hasAlpha)
            {
                // Fall back to transcode RGB-only to RGBA texture
                formats = TranscodeFormatHelper.GetPreferredFormat(
                    false,
                    li.isPowerOfTwo,
                    li.isSquare,
                    linear
                    );
            }
            return(formats);
        }
예제 #27
0
 public virtual void ProcessAttributes(IMetaData metaData, ICustomAttributeProvider attributeProvider)
 {
     foreach (AttributeProcessor processor in AttributeProcessors)
     {
         processor.Process(metaData, attributeProvider, this.Config);
     }
 }
예제 #28
0
        private void GenerateCode(GenerationParameter parameter, ITemplateEngine templateEngine, string templateName,
                                  ref int genratedCount, ref int errorCount, ref int progressCount, AsyncOperation asyncOp)
        {
            foreach (string modelId in parameter.GenerationObjects.Keys)
            {
                string codeFileNamePath = PathHelper.GetCodeFileNamePath(ConfigManager.GenerationCodeOuputPath,
                                                                         ConfigManager.SettingsSection.Languages[parameter.Settings.Language].Alias,
                                                                         ConfigManager.SettingsSection.TemplateEngines[parameter.Settings.TemplateEngine].Name,
                                                                         ConfigManager.TemplateSection.Templates[templateName].DisplayName, parameter.Settings.Package, modelId);
                PathHelper.CreateCodeFileNamePath(codeFileNamePath);

                foreach (string objId in parameter.GenerationObjects[modelId])
                {
                    IMetaData    modelObject  = ModelManager.GetModelObject(parameter.Models[modelId], objId);
                    TemplateData templateData = TemplateDataBuilder.Build(modelObject, parameter.Settings,
                                                                          templateName, parameter.Models[modelId].Database, modelId);

                    if (templateData == null || !templateEngine.Run(templateData))
                    {
                        errorCount++;
                    }
                    else
                    {
                        genratedCount++;
                    }
                    string currentCodeFileName = templateData == null ? string.Empty : templateData.CodeFileName;

                    var args = new GenerationProgressChangedEventArgs(genratedCount,
                                                                      errorCount, currentCodeFileName, ++progressCount, asyncOp.UserSuppliedState);
                    asyncOp.Post(this.onProgressReportDelegate, args);
                }
            }
        }
예제 #29
0
        private void btnCreateTableSQL_Click(Object sender, EventArgs e)
        {
            if (cbConn.SelectedItem == null)
            {
                return;
            }

            IDataTable table = GetSelectedTable();

            if (table == null)
            {
                return;
            }

            var dal = DAL.Create("" + cbConn.SelectedItem);

            if (dal == null)
            {
                return;
            }

            try
            {
                IMetaData md  = dal.Db.CreateMetaData();
                var       sql = CreateTable(md, table);

                FrmText.Create(table.TableName + "表建表语句", sql).Show();
            }
            catch (Exception ex)
            {
                FrmText.Create(table.TableName + "表建表语句", "生成建表语句错误!" + Environment.NewLine + ex.ToString()).Show();
            }
        }
예제 #30
0
    private void ReadWriteData()
    {
        m_Text = this.GetText();

        IMetaData metaData = Singleton.GetDataManager().MetaData;

        Debug.Log("End datetime: " + metaData.EndDateTimeNumber);

        m_Text.text = "";
        // Start time
        m_Text.text += "\nStart time:\t\t" + Utils.TryConvertDoubleToDateTimeString(metaData.StartDateTimeNumber);
        // End time
        m_Text.text += "\nEnd time:\t\t\t" + Utils.TryConvertDoubleToDateTimeString(metaData.EndDateTimeNumber);
        // List parameters
        m_Text.text += "\nVariables:\t\t\t";
        for (int i = 0; i < metaData.Variables.Count; i++)
        {
            m_Text.text += metaData.Variables[i].Name + " ( Min: " + metaData.Variables[i].Min + ", Max: " + metaData.Variables[i].Max + " )";

            if (i != metaData.Variables.Count - 1)
            {
                m_Text.text += "\n\t\t\t\t";
            }
        }
        // Number of levels
        m_Text.text += "\nAlt. pres. levels:\t\t" + metaData.Levels.ToString();
        // Hour intervals
        m_Text.text += "\nHourly interval:\t\t" + metaData.TimeInterval.ToString();
        // Height
        m_Text.text += "\nHeight:\t\t\t" + metaData.Height.ToString();
        // Width
        m_Text.text += "\nWidth:\t\t\t" + metaData.Width.ToString();
        // Bit depth
        m_Text.text += "\nBit depth:\t\t\t" + metaData.BitDepth.ToString();
    }
예제 #31
0
        private void btnCreateDbSQL_Click(Object sender, EventArgs e)
        {
            if (cbConn.SelectedItem == null)
            {
                return;
            }

            var dal = DAL.Create("" + cbConn.SelectedItem);

            if (dal == null)
            {
                return;
            }

            try
            {
                IMetaData md = dal.Db.CreateMetaData();
                var       sb = new StringBuilder();
                foreach (var table in Tables)
                {
                    var sql = CreateTable(md, table);
                    if (!String.IsNullOrEmpty(sql))
                    {
                        sb.AppendLine(sql);
                    }
                }

                FrmText.Create("建表语句", sb.ToString()).Show();
            }
            catch (Exception ex)
            {
                FrmText.Create("建表语句", "生成建表语句错误!" + Environment.NewLine + ex.ToString()).Show();
            }
        }
        public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, ISerializerSettings config)
        {
            if (metaData is IPropertyData)
            {
                IPropertyData          property    = (IPropertyData)metaData;
                JsonExDefaultAttribute defaultAttr = ReflectionUtils.GetAttribute <JsonExDefaultAttribute>(attributeProvider, false);
                if (defaultAttr != null)
                {
                    switch (defaultAttr.DefaultValueSetting)
                    {
                    case DefaultValueOption.InheritParentSetting:
                    case DefaultValueOption.SuppressDefaultValues:
                        property.DefaultValueSetting = defaultAttr.DefaultValueSetting;
                        if (defaultAttr.DefaultValueSet)
                        {
                            property.DefaultValue = defaultAttr.DefaultValue;
                        }
                        break;

                    case DefaultValueOption.WriteAllValues:
                        property.DefaultValueSetting = defaultAttr.DefaultValueSetting;
                        break;
                    }
                }
            }
            else if (metaData is TypeData)
            {
                Type     classType = metaData.ForType;
                TypeData typeData  = (TypeData)metaData;
                // apply assembly defaults first
                AssemblyCache cache = GetAssemblyCache(classType, config);
                if (cache.defaultValues != null)
                {
                    typeData.DefaultValues = new DefaultValueCollection(cache.defaultValues);
                }
                if (cache.defaultOption != DefaultValueOption.InheritParentSetting)
                {
                    typeData.DefaultValueSetting = cache.defaultOption;
                }

                bool typeSet = false;
                foreach (JsonExDefaultValuesAttribute attr in attributeProvider.GetCustomAttributes(typeof(JsonExDefaultValuesAttribute), false))
                {
                    if (attr.DefaultValueSetting != DefaultValueOption.InheritParentSetting)
                    {
                        typeData.DefaultValueSetting = attr.DefaultValueSetting;
                    }
                    if (attr.Type != null)
                    {
                        typeData.DefaultValues[attr.Type] = attr.DefaultValue;
                        typeSet = true;
                    }
                }
                if (typeData.DefaultValueSetting == DefaultValueOption.InheritParentSetting && typeSet)
                {
                    typeData.DefaultValueSetting = DefaultValueOption.SuppressDefaultValues;
                }
            }
        }
예제 #33
0
		public MetaDataTableNode(HexDocument doc, MDTable mdTable, IMetaData md)
			: base((ulong)mdTable.StartOffset, (ulong)mdTable.EndOffset - 1) {
			this.doc = doc;
			this.tableInfo = mdTable.TableInfo;
			this.tablesStreamVM = MetaDataTableVM.Create(this, doc, StartOffset, mdTable);
			this.tablesStreamVM.FindMetaDataTable = FindMetaDataTable;
			this.tablesStreamVM.InitializeHeapOffsets((ulong)md.StringsStream.StartOffset, (ulong)md.StringsStream.EndOffset - 1);
		}
예제 #34
0
 public CssSpriteCreator(ICacheManager cacheManager, IRetryableFileOpener retryableFileOpener, IPathProvider pathProvider, IRetryableFileWriter retryableFileWriter, IMetaData fileMetaData)
 {
     CacheManager = cacheManager;
     RetryableFileOpener = retryableFileOpener;
     PathProvider = pathProvider;
     RetryableFileWriter = retryableFileWriter;
     FileMetaData = fileMetaData;
 }
예제 #35
0
 public Delta(IConfiguration configuration)
 {
     _mapping             = configuration.GetMapping(typeof(T));
     ObjectPropertyValues = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
     CollectionDeltas     = new Dictionary <string, ICollectionDelta>();
     TopLevelMetaData     = null;
     ObjectMetaData       = null;
 }
예제 #36
0
 public MDTableModel(MDTableHeapModel parent, IMetaData metadata, TablesStream stream, MDTable table)
 {
     Parent   = parent;
     MetaData = metadata;
     Tables   = stream;
     MDTable  = table;
     Text     = string.Format("{0:x2}: {1} (0x{2:x})", (byte)table.Table, table.Name, table.Rows);
 }
예제 #37
0
		public TablesStreamTreeNode(HexDocument doc, TablesStream tblStream, IMetaData md)
			: base((ulong)tblStream.StartOffset, (ulong)tblStream.MDTables[0].StartOffset - 1) {
			this.tablesStreamVM = new TablesStreamVM(this, doc, tblStream);

			foreach (var mdTable in tblStream.MDTables) {
				if (mdTable.Rows != 0)
					this.Children.Add(new MetaDataTableTreeNode(doc, mdTable, md));
			}
		}
예제 #38
0
		public MetaDataTableNode(HexBuffer buffer, MDTable mdTable, IMetaData md)
			: base(HexSpan.FromBounds((ulong)mdTable.StartOffset, (ulong)mdTable.EndOffset)) {
			Buffer = buffer;
			TableInfo = mdTable.TableInfo;
			var stringsHeapSpan = HexSpan.FromBounds((ulong)md.StringsStream.StartOffset, (ulong)md.StringsStream.EndOffset);
			var guidHeapSpan = HexSpan.FromBounds((ulong)md.GuidStream.StartOffset, (ulong)md.GuidStream.EndOffset);
			MetaDataTableVM = MetaDataTableVM.Create(this, buffer, Span.Start, mdTable, stringsHeapSpan, guidHeapSpan);
			MetaDataTableVM.FindMetaDataTable = FindMetaDataTable;
		}
 public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
 {
     if (metaData is IPropertyData)
     {
         IPropertyData property = (IPropertyData)metaData;
         if (attributeProvider.IsDefined(typeof(XmlIgnoreAttribute), false))
             property.Ignored = true;
     }
 }
예제 #40
0
 public JsCrusher(ICacheManager cacheManager, IPathProvider pathProvider, IRetryableFileOpener retryableFileOpener, IRetryableFileWriter retryableFileWriter, IMetaData fileMetaData)
 {
     CacheManager = cacheManager;
     PathProvider = pathProvider;
     RetryableFileOpener = retryableFileOpener;
     RetryableFileWriter = retryableFileWriter;
     FileMetaData = fileMetaData;
     YahooYuiJavaScriptCompressorPool = new Pool<JavaScriptCompressor>(64, pool => new JavaScriptCompressor(), LoadingMode.LazyExpanding, AccessMode.Circular);
     MicrosoftAjaxMinJavaScriptCompressorPool = new Pool<Minifier>(64, pool => new Minifier(), LoadingMode.LazyExpanding, AccessMode.Circular);
 }
예제 #41
0
		public StorageStreamNode(HexBuffer buffer, StreamHeader sh, int streamNumber, DotNetStream knownStream, IMetaData md)
			: base(HexSpan.FromBounds((ulong)sh.StartOffset, (ulong)sh.EndOffset)) {
			StreamNumber = streamNumber;
			StorageStreamType = GetStorageStreamType(knownStream);
			storageStreamVM = new StorageStreamVM(buffer, Span.Start, (int)(Span.Length - 8).ToUInt64());

			var tblStream = knownStream as TablesStream;
			if (tblStream != null)
				newChild = new TablesStreamNode(buffer, tblStream, md);
		}
예제 #42
0
		public StorageStreamNode(HexDocument doc, StreamHeader sh, int streamNumber, DotNetStream knownStream, IMetaData md)
			: base((ulong)sh.StartOffset, (ulong)sh.EndOffset - 1) {
			this.streamNumber = streamNumber;
			this.storageStreamType = GetStorageStreamType(knownStream);
			this.storageStreamVM = new StorageStreamVM(this, doc, StartOffset, (int)(EndOffset - StartOffset + 1 - 8));

			var tblStream = knownStream as TablesStream;
			if (tblStream != null)
				this.newChild = new TablesStreamNode(doc, tblStream, md);
		}
예제 #43
0
		public TablesStreamNode(HexBuffer buffer, TablesStream tblStream, IMetaData md)
			: base(HexSpan.FromBounds((ulong)tblStream.StartOffset, (ulong)tblStream.MDTables[0].StartOffset)) {
			tablesStreamVM = new TablesStreamVM(buffer, tblStream);

			newChildren = new List<TreeNodeData>();
			foreach (var mdTable in tblStream.MDTables) {
				if (mdTable.Rows != 0)
					newChildren.Add(new MetaDataTableNode(buffer, mdTable, md));
			}
		}
예제 #44
0
		/// <summary>
		/// Creates a new <see cref="ISymbolReader"/> instance
		/// </summary>
		/// <param name="pdbImpl">PDB implementation to use</param>
		/// <param name="metaData">.NET metadata. Only need to be non-null if MS COM API should be used</param>
		/// <param name="pdbData">PDB file data</param>
		/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c> if it's not possible
		/// to create a <see cref="ISymbolReader"/>.</returns>
		public static ISymbolReader Create(PdbImplType pdbImpl, IMetaData metaData, byte[] pdbData) {
			switch (pdbImpl) {
			case PdbImplType.MicrosoftCOM:
				return Dss.SymbolReaderCreator.Create(metaData, pdbData);

			case PdbImplType.Managed:
				return Managed.SymbolReaderCreator.Create(pdbData);

			default: throw new InvalidOperationException();
			}
		}
예제 #45
0
		/// <summary>
		/// Creates a new <see cref="ISymbolReader"/> instance
		/// </summary>
		/// <param name="metaData">.NET metadata</param>
		/// <param name="pdbFileName">Path to PDB file</param>
		/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c> if there's no PDB
		/// file on disk or if any of the COM methods fail.</returns>
		public static ISymbolReader Create(IMetaData metaData, string pdbFileName) {
			var mdStream = CreateMetaDataStream(metaData);
			try {
				return Create(mdStream, OpenImageStream(pdbFileName));
			}
			catch {
				if (mdStream != null)
					mdStream.Dispose();
				throw;
			}
		}
예제 #46
0
 public CssCrusher(ICacheManager cacheManager, IPathProvider pathProvider, IRetryableFileOpener retryableFileOpener, IRetryableFileWriter retryableFileWriter, ICssPathRewriter cssPathRewriter, IMetaData fileMetaData, bool watchAssets)
 {
     CacheManager = cacheManager;
     PathProvider = pathProvider;
     RetryableFileOpener = retryableFileOpener;
     RetryableFileWriter = retryableFileWriter;
     CssPathRewriter = cssPathRewriter;
     FileMetaData = fileMetaData;
     WatchAssets = watchAssets;
     YahooYuiCssCompressorPool = new Pool<Yahoo.Yui.Compressor.CssCompressor>(64, pool => new Yahoo.Yui.Compressor.CssCompressor(), LoadingMode.LazyExpanding, AccessMode.Circular);
     MicrosoftAjaxMinCssCompressorPool = new Pool<Microsoft.Ajax.Utilities.Minifier>(64, pool => new Microsoft.Ajax.Utilities.Minifier(), LoadingMode.LazyExpanding, AccessMode.Circular);
 }
예제 #47
0
        public CrusherMsBuildCommand(string applicationPath, string binDirectoryPath, string configPath, Action<string> logMessage, Action<string> logError)
        {
            if (string.IsNullOrEmpty(applicationPath))
            {
                throw new ArgumentNullException("applicationPath");
            }

            if (string.IsNullOrEmpty(binDirectoryPath))
            {
                throw new ArgumentNullException("binDirectoryPath");
            }

            if (string.IsNullOrEmpty(configPath))
            {
                throw new ArgumentNullException("configPath");
            }

            if (logMessage == null)
            {
                throw new ArgumentNullException("logMessage");
            }

            if (logError == null)
            {
                throw new ArgumentNullException("logError");
            }

            _applicationPath = applicationPath;
            _binDirectoryPath = binDirectoryPath;
            _configPath = configPath;
            _logMessage = logMessage;
            _logError = logError;

            _retryableFileOpener = new RetryableFileOpener();
            _hasher = new Hasher(_retryableFileOpener);
            _retryableFileWriter = new RetryableFileWriter(BufferSize, Encoding, _retryableFileOpener, _hasher);
            _fileMetaData = new MultiFileMetaData(_retryableFileOpener, _retryableFileWriter);

            _cssSpriteConfiguration = GetCssSpriteSection(_configPath, CssSpriteSectionName);
            _crusherConfiguration = GetCrusherSection(_configPath, CrusherSectionName);

            var configUri = new Uri(_configPath, UriKind.RelativeOrAbsolute);
            if (!configUri.IsAbsoluteUri)
            {
                configUri = new Uri(Path.Combine(Environment.CurrentDirectory, configUri.ToString()));
            }

            var physicalApplicationPath = new FileInfo(configUri.LocalPath).DirectoryName;
            _pathProvider = new PathProvider(_applicationPath, physicalApplicationPath);
            _cacheManager = new HttpCacheManager();
        }
예제 #48
0
        private CssSpriteManager()
        {
            var retryableFileOpener = new RetryableFileOpener();
            var hasher = new Md5Hasher(retryableFileOpener);
			var retryableFileWriter = new RetryableFileWriter(BufferSize, _encoding, retryableFileOpener, hasher);

            var cacheManager = new HttpCacheManager();
			_pathProvider = new PathProvider();
            var cssSpriteMetaDataFileInfo = new FileInfo("cssSprite.metadata");
            _cssSpriteMetaData = new SingleFileMetaData(cssSpriteMetaDataFileInfo, retryableFileOpener, retryableFileWriter);
			_cssSpriteCreator = new CssSpriteCreator(cacheManager, retryableFileOpener, _pathProvider, retryableFileWriter, _cssSpriteMetaData);
            
            InitManager();
        }
        public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
        {
            if (metaData is IPropertyData)
            {
                IPropertyData property = (IPropertyData)metaData;
                JsonExDefaultAttribute defaultAttr = ReflectionUtils.GetAttribute<JsonExDefaultAttribute>(attributeProvider, false);
                if (defaultAttr != null)
                {
                    switch (defaultAttr.DefaultValueSetting)
                    {
                        case DefaultValueOption.InheritParentSetting:
                        case DefaultValueOption.SuppressDefaultValues:
                            property.DefaultValueSetting = defaultAttr.DefaultValueSetting;
                            if (defaultAttr.DefaultValueSet)
                                property.DefaultValue = defaultAttr.DefaultValue;
                            break;
                        case DefaultValueOption.WriteAllValues:
                            property.DefaultValueSetting = defaultAttr.DefaultValueSetting;
                            break;
                    }
                }
            }
            else if (metaData is TypeData)
            {
                Type classType = metaData.ForType;
                TypeData typeData = (TypeData)metaData;
                // apply assembly defaults first
                AssemblyCache cache = GetAssemblyCache(classType, config);
                if (cache.defaultValues != null)
                {
                    typeData.DefaultValues = new DefaultValueCollection(cache.defaultValues);
                }
                if (cache.defaultOption != DefaultValueOption.InheritParentSetting)
                    typeData.DefaultValueSetting = cache.defaultOption;

                bool typeSet = false;
                foreach (JsonExDefaultValuesAttribute attr in attributeProvider.GetCustomAttributes(typeof(JsonExDefaultValuesAttribute), false))
                {
                    if (attr.DefaultValueSetting != DefaultValueOption.InheritParentSetting)
                        typeData.DefaultValueSetting = attr.DefaultValueSetting;
                    if (attr.Type != null)
                    {
                        typeData.DefaultValues[attr.Type] = attr.DefaultValue;
                        typeSet = true;
                    }
                }
                if (typeData.DefaultValueSetting == DefaultValueOption.InheritParentSetting && typeSet)
                    typeData.DefaultValueSetting = DefaultValueOption.SuppressDefaultValues;
            }
        }
예제 #50
0
 public JsCrusher(ICacheManager cacheManager, IPathProvider pathProvider, IRetryableFileOpener retryableFileOpener, IRetryableFileWriter retryableFileWriter, IMetaData fileMetaData)
 {
     CacheManager = cacheManager;
     PathProvider = pathProvider;
     RetryableFileOpener = retryableFileOpener;
     RetryableFileWriter = retryableFileWriter;
     FileMetaData = fileMetaData;
     YahooYuiJavaScriptCompressorPool = new Pool<Yahoo.Yui.Compressor.JavaScriptCompressor>(4, pool => new Yahoo.Yui.Compressor.JavaScriptCompressor(), LoadingMode.LazyExpanding, AccessMode.Circular);
     MicrosoftAjaxMinJavaScriptCompressorPool = new Pool<Microsoft.Ajax.Utilities.Minifier>(44, pool => new Microsoft.Ajax.Utilities.Minifier(), LoadingMode.LazyExpanding, AccessMode.Circular);
     CoffeeCompilerPool = new Pool<Coffee.CoffeeCompiler>(4, pool => new Coffee.CoffeeCompiler(new EmbeddedResourceLoader()), LoadingMode.LazyExpanding, AccessMode.Circular);
     IcedCoffeeCompilerPool = new Pool<IcedCoffee.IcedCoffeeCompiler>(4, pool => new IcedCoffee.IcedCoffeeCompiler(new EmbeddedResourceLoader()), LoadingMode.LazyExpanding, AccessMode.Circular);
     LiveScriptCompilerPool = new Pool<LiveScript.LiveScriptCompiler>(4, pool => new LiveScript.LiveScriptCompiler(new EmbeddedResourceLoader()), LoadingMode.LazyExpanding, AccessMode.Circular);
     HoganCompilerPool = new Pool<Hogan.HoganCompiler>(4, pool => new Hogan.HoganCompiler(new EmbeddedResourceLoader()), LoadingMode.LazyExpanding, AccessMode.Circular);
 }
예제 #51
0
		/// <summary>
		/// Creates a new <see cref="ISymbolReader"/> instance
		/// </summary>
		/// <param name="pdbImpl">PDB implementation to use</param>
		/// <param name="metaData">.NET metadata. Only need to be non-null if MS COM API should be used</param>
		/// <param name="pdbStream">PDB file stream which is now owned by us</param>
		/// <returns>A new <see cref="ISymbolReader"/> instance or <c>null</c> if it's not possible
		/// to create a <see cref="ISymbolReader"/>.</returns>
		public static ISymbolReader Create(PdbImplType pdbImpl, IMetaData metaData, IImageStream pdbStream) {
			switch (pdbImpl) {
			case PdbImplType.MicrosoftCOM:
				return Dss.SymbolReaderCreator.Create(metaData, pdbStream);

			case PdbImplType.Managed:
				return Managed.SymbolReaderCreator.Create(pdbStream);

			default:
				if (pdbStream != null)
					pdbStream.Dispose();
				throw new InvalidOperationException();
			}
		}
예제 #52
0
        private CrusherManager()
        {
            _crusherConfiguration = CurrentCrusherConfiguration.Current;

            _retryableFileOpener = new RetryableFileOpener();
            _hasher = new Md5Hasher(_retryableFileOpener);
			_retryableFileWriter = new RetryableFileWriter(BufferSize, _encoding, _retryableFileOpener, _hasher);
            _pathProvider = new PathProvider();

            _cacheManager = new HttpCacheManager();
            _fileMetaData = new MultiFileMetaData(_retryableFileOpener, _retryableFileWriter);
 
            InitManager();
        }
예제 #53
0
		public bool MakePublic() {
			try {
				md = MetaDataCreator.CreateMetaData(new PEImage(data));
			}
			catch (BadImageFormatException) {
				return false;
			}

			UpdateTypeDefTable();
			UpdateFieldTable();
			UpdateMethodTable();
			UpdateExportedTypeTable();

			return true;
		}
 public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
 {
     if (metaData is IPropertyData)
     {
         IPropertyData property = (IPropertyData) metaData;
         JsonExPropertyAttribute attr = ReflectionUtils.GetAttribute<JsonExPropertyAttribute>(attributeProvider, false);
         if (attr != null)
         {
             property.Ignored = false;
             if (!string.IsNullOrEmpty(attr.Alias))
             {
                 property.Alias = attr.Alias;
             }
         }
     }
 }
        public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
        {
            if (metaData is IPropertyData)
            {
                IPropertyData property = (IPropertyData)metaData;
                ConstructorParameterAttribute ctorAttr = ReflectionUtils.GetAttribute<ConstructorParameterAttribute>(attributeProvider, false);
                if (ctorAttr != null)
                {
                    if (ctorAttr.Position >= 0)
                        property.Position = ctorAttr.Position;
                    else if (!string.IsNullOrEmpty(ctorAttr.Name))
                        property.ConstructorParameterName = ctorAttr.Name;
                    else
                        property.ConstructorParameterName = property.Name;

                    property.Ignored = false;
                }

            }
        }
        public override void Process(IMetaData metaData, ICustomAttributeProvider attributeProvider, IConfiguration config)
        {
            TypeData typeData = metaData as TypeData;
            if (typeData == null)
                return;

            JsonExCollectionAttribute attr = ReflectionUtils.GetAttribute<JsonExCollectionAttribute>(attributeProvider, true);
            if (attr == null)
                return;

            if (!attr.IsValid())
                throw new Exception("Invalid JsonExCollectionAttribute specified for " + attributeProvider + ", either CollectionHandlerType or ItemType or both must be specified");

            

            Type collHandlerType = attr.GetCollectionHandlerType();
            Type itemType = attr.GetItemType();

            // Try exact type match first
            CollectionHandler handler = null;

            if (collHandlerType == null)
            {
                handler = typeData.FindCollectionHandler();
                handler = new CollectionHandlerWrapper(handler, typeData.ForType, itemType);
            }

            bool registerHandler = false;
            if (handler == null)
            {
                handler = ConstructOrFindHandler(config, collHandlerType, ref registerHandler);
            }

            typeData.CollectionHandler = handler;
            // install the handler
            if (registerHandler)
                config.RegisterCollectionHandler(handler);
            
        }
예제 #57
0
		static IImageStream CreateMetaDataStream(IMetaData metaData) {
			var peImage = metaData.PEImage;
			var mdDataDir = metaData.ImageCor20Header.MetaData;
			return peImage.CreateStream(mdDataDir.VirtualAddress, mdDataDir.Size);
		}
 public MigrationDefinitionFactoryBuilder(IMetaData metaData)
 {
     this.metaData = metaData;
 }
예제 #59
0
		/// <inheritdoc/>
		public void Dispose() {
			var md = metaData;
			if (md != null)
				md.Dispose();
			metaData = null;
		}
예제 #60
0
		DotNetFile(IMetaData metaData) {
			this.metaData = metaData;
		}