示例#1
0
        /// <summary>
        /// Serializes the object using specified etalon.
        /// </summary>
        /// <param name="obj">The object to serialize.</param>
        /// <param name="diff">The etalon object.</param>
        public void Write(IFRSerializable obj, object diff)
        {
            if (obj == null)
            {
                return;
            }
            XmlItem       saveCurItem       = FCurItem;
            XmlItem       saveCurRoot       = FCurRoot;
            StringBuilder saveText          = FText;
            object        saveDiffObject    = FDiffObject;
            bool          destroyDiffObject = false;

            try
            {
                FText       = new StringBuilder();
                FCurItem    = FCurItem == null ? FRoot : FCurItem.Add();
                FCurRoot    = FCurItem;
                FDiffObject = diff;
                if (obj is Base && SerializeTo == SerializeTo.Preview)
                {
                    FDiffObject   = (obj as Base).OriginalComponent;
                    FCurItem.Name = FDiffObject != null ? (obj as Base).Alias : (obj as Base).ClassName;
                }
                if (GetDiff != null)
                {
                    DiffEventArgs e = new DiffEventArgs();
                    e.Object = obj;
                    GetDiff(this, e);
                    FDiffObject = e.DiffObject;
                }
                if (FDiffObject == null)
                {
                    try
                    {
                        FDiffObject       = Activator.CreateInstance(obj.GetType());
                        destroyDiffObject = true;
                    }
                    catch
                    {
                    }
                }
                obj.Serialize(this);
            }
            finally
            {
                if (FText.Length > 0)
                {
                    FText.Remove(FText.Length - 1, 1);
                }
                FCurRoot.Text = FText.ToString();
                FText         = saveText;
                FCurItem      = saveCurItem;
                FCurRoot      = saveCurRoot;
                if (destroyDiffObject && FDiffObject is IDisposable)
                {
                    (FDiffObject as IDisposable).Dispose();
                }
                FDiffObject = saveDiffObject;
            }
        }
示例#2
0
        /// <summary>
        /// Serializes the object using specified etalon.
        /// </summary>
        /// <param name="obj">The object to serialize.</param>
        /// <param name="diff">The etalon object.</param>
        public void Write(IFRSerializable obj, object diff)
        {
            if (obj == null)
            {
                return;
            }
            XmlItem saveCurItem = curItem;
            XmlItem saveCurRoot = curRoot;
            //StringBuilder saveText = FText;
            object saveDiffObject = diffObject;

            try
            {
                //FText = new StringBuilder();
                curItem    = curItem == null ? root : curItem.Add();
                curRoot    = curItem;
                diffObject = diff;
                if (obj is Base && SerializeTo == SerializeTo.Preview)
                {
                    diffObject   = (obj as Base).OriginalComponent;
                    curItem.Name = diffObject != null ? (obj as Base).Alias : (obj as Base).ClassName;
                }
                if (GetDiff != null)
                {
                    DiffEventArgs e = new DiffEventArgs();
                    e.Object = obj;
                    GetDiff(this, e);
                    diffObject = e.DiffObject;
                }
                if (diffObject == null)
                {
                    try
                    {
                        Type objType = obj.GetType();
                        if (!diffObjects.Contains(objType))
                        {
                            diffObjects[objType] = Activator.CreateInstance(objType);
                        }
                        diffObject = diffObjects[objType];
                    }
                    catch
                    {
                    }
                }
                obj.Serialize(this);
            }
            finally
            {
                //if (FText.Length > 0)
                //          FText.Remove(FText.Length - 1, 1);
                //FCurRoot.Text = FText.ToString();
                //FText = saveText;
                curItem    = saveCurItem;
                curRoot    = saveCurRoot;
                diffObject = saveDiffObject;
            }
        }
示例#3
0
 public void Save(XmlItem rootItem)
 {
     foreach (BlobItem item in FList)
     {
         XmlItem xi = rootItem.Add();
         xi.Name = "item";
         xi.SetProp("Stream", Converter.ToXml(item.Stream));
     }
 }
示例#4
0
 public void Save(XmlItem rootItem)
 {
     foreach (BlobItem item in list)
     {
         XmlItem xi = rootItem.Add();
         xi.Name = "item";
         xi.SetProp("Stream", Converter.ToXml(item.Stream));
         if (!String.IsNullOrEmpty(item.Source))
         {
             xi.SetProp("Source", Converter.ToXml(item.Source));
         }
         if (TempFile != null)
         {
             item.Dispose();
         }
     }
 }
示例#5
0
        public static void CreateFunctionsTree(Report report, ObjectInfo rootItem, XmlItem rootNode)
        {
            foreach (ObjectInfo item in rootItem.Items)
            {
                string     text = String.Empty;
                string     desc = String.Empty;
                MethodInfo func = item.Function;
                if (func != null)
                {
                    text = func.Name;
                    // if this is an overridden function, show its parameters
                    if (rootItem.Name == text)
                    {
                        text = report.CodeHelper.GetMethodSignature(func, false);
                    }
                    desc = GetFunctionDescription(report, func);
                }
                else
                {
                    // it's a category
                    text = Res.TryGet(item.Text);
                }
                XmlItem node = rootNode.Add();
                node.SetProp("Name", text);
                if (!String.IsNullOrEmpty(desc))
                {
                    node.SetProp("Description", desc);
                }

                if (item.Items.Count > 0)
                {
                    node.Name = "Functions";
                    CreateFunctionsTree(report, item, node);
                }
                else
                {
                    node.Name = "Function";
                }
            }
        }