コード例 #1
0
ファイル: WcfPortal.cs プロジェクト: zuiwanting/csla
        public WcfResponse Fetch(CriteriaRequest request)
        {
            Csla.Server.DataPortal portal     = new Csla.Server.DataPortal();
            Exception               error     = null;
            DataPortalResult        result    = null;
            WcfResponse             response  = null;
            ISerializationFormatter formatter = SerializationFormatterFactory.GetFormatter();

            try
            {
                request = ConvertRequest(request);
                DataPortalContext context = new DataPortalContext(
                    formatter.Deserialize(request.Principal) as IPrincipal,
                    true,
                    request.ClientCulture,
                    request.ClientUICulture,
                    formatter.Deserialize(request.ClientContext) as ContextDictionary,
                    formatter.Deserialize(request.GlobalContext) as ContextDictionary);
                result   = portal.Fetch(Type.GetType(request.TypeName), formatter.Deserialize(request.CriteriaData), context);
                response = new WcfResponse(
                    formatter.Serialize(result.ReturnObject),
                    formatter.Serialize(error),
                    formatter.Serialize(Csla.ApplicationContext.GlobalContext));
            }
            catch (Exception ex)
            {
                error    = ex;
                response = new WcfResponse(
                    null,
                    formatter.Serialize(error),
                    formatter.Serialize(Csla.ApplicationContext.GlobalContext));
            }
            return(ConvertResponse(response));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name">A name for this tree, for your reference</param>
        /// <param name="globalRootItemPath">The 'global' path where this tree is rooted. For example, if this was '/sitecore/content', the root item in this tree would be 'content'</param>
        /// <param name="databaseName">Name of the database the items in this tree are from. This is for your reference and help when resolving this tree as a destination, and is not directly used.</param>
        /// <param name="physicalRootPath">The physical root path to write items in this tree to. Will be created if it does not exist.</param>
        /// <param name="formatter">The formatter to use when reading or writing items to disk</param>
        /// <param name="useDataCache">Whether to cache items read in memory for later rapid retrieval. Great for small trees, or if you have plenty of RAM. Bad for media trees :)</param>
        public SerializationFileSystemTree(string name, string globalRootItemPath, string databaseName, string physicalRootPath, ISerializationFormatter formatter, bool useDataCache)
        {
            Assert.ArgumentNotNullOrEmpty(globalRootItemPath, "globalRootItemPath");
            Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, "physicalRootPath");
            Assert.ArgumentNotNull(formatter, "formatter");
            Assert.IsTrue(globalRootItemPath.StartsWith("/"), "The global root item path must start with '/', e.g. '/sitecore' or '/sitecore/content'");
            Assert.IsTrue(globalRootItemPath.Length > 1, "The global root item path cannot be '/' - there is no root item. You probably mean '/sitecore'.");

            _globalRootItemPath = globalRootItemPath.TrimEnd('/');
            // enforce that the physical root path is filesystem-safe
            AssertValidPhysicalPath(physicalRootPath);
            _physicalRootPath = physicalRootPath;
            _formatter        = formatter;
            _dataCache        = new FsCache <IItemData>(useDataCache);
            Name         = name;
            DatabaseName = databaseName;

            if (!Directory.Exists(_physicalRootPath))
            {
                Directory.CreateDirectory(_physicalRootPath);
            }

            _treeWatcher = new TreeWatcher(_physicalRootPath, _formatter.FileExtension, HandleDataItemChanged);
        }
コード例 #3
0
ファイル: WcfProxy.cs プロジェクト: eugene-h-lin/csla-svn
        /// <summary>
        /// Called by <see cref="DataPortal" /> to create a
        /// new business object.
        /// </summary>
        /// <param name="objectType">Type of business object to create.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" /> object passed to the server.
        /// </param>
        public DataPortalResult Create(Type objectType, object criteria, DataPortalContext context)
        {
            ChannelFactory <IExtendableWcfPortalForDotNet> cf = GetChannelFactory();
            IExtendableWcfPortalForDotNet svr = GetProxy(cf);
            WcfResponse             response  = null;
            ISerializationFormatter formatter = SerializationFormatterFactory.GetFormatter();

            try
            {
                response =
                    svr.Create(GetRequest(formatter, objectType, criteria, context));
                if (cf != null)
                {
                    cf.Close();
                }
            }
            catch
            {
                cf.Abort();
                throw;
            }
            DataPortalResult result = GetResult(formatter, response);
            Exception        error  = (Exception)formatter.Deserialize(response.Error);

            if (error != null)
            {
                throw error;
            }
            return(result);
        }
コード例 #4
0
        public static ISerializationFormatter GetFormatter <T>(SerializationType type)
        {
            ISerializationFormatter obj = null;

            switch (type)
            {
            case SerializationType.BinaryFormatter:
                obj = new BinaryFormatterWrapper();
                break;

            case SerializationType.XmlSerializer:
                obj = new XmlSerializerWrapper <T>();
                break;

            case SerializationType.NetDataContractSerializer:
                obj = new NetDataContractSerializerWrapper();
                break;

            case SerializationType.Json:
                obj = new DataContractJsonSerializer <T>();
                break;

            default:
                obj = new BinaryFormatterWrapper();
                break;
            }
            return(obj);
        }
コード例 #5
0
		public RainbowItemDeserializer()
		{
			// TODO: See if we can move this to a config file, rather than hard coding it here.
			const string xmlNodeString = @"
				<serializationFormatter type=""Rainbow.Storage.Yaml.YamlSerializationFormatter, Rainbow.Storage.Yaml"" singleInstance=""true"">
					<fieldFormatter type=""Rainbow.Formatting.FieldFormatters.MultilistFormatter, Rainbow"" />
                    <fieldFormatter type=""Rainbow.Formatting.FieldFormatters.XmlFieldFormatter, Rainbow"" />
                  </serializationFormatter >
			";
			var doc = new XmlDocument();
			doc.LoadXml(xmlNodeString);

			// TODO: See if we can move this to a config file, rather than hard coding it here.
			const string fieldFilterXmlString = @"
				<fieldFilter type=""Rainbow.Filtering.ConfigurationFieldFilter, Rainbow"" singleInstance=""true"">
					<exclude fieldID=""{B1E16562-F3F9-4DDD-84CA-6E099950ECC0}"" note=""'Last run' field on Schedule template (used to register tasks)"" />
					<exclude fieldID=""{52807595-0F8F-4B20-8D2A-CB71D28C6103}"" note=""'__Owner' field on Standard Template"" />
					<exclude fieldID=""{F6D8A61C-2F84-4401-BD24-52D2068172BC}"" note=""'__Originator' field on Standard Template"" />
					<exclude fieldID=""{8CDC337E-A112-42FB-BBB4-4143751E123F}"" note=""'__Revision' field on Standard Template"" />
					<exclude fieldID=""{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}"" note=""'__Updated' field on Standard Template"" />
					<exclude fieldID=""{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}"" note=""'__Updated by' field on Standard Template"" />
					<exclude fieldID=""{001DD393-96C5-490B-924A-B0F25CD9EFD8}"" note=""'__Lock' field on Standard Template"" />
				</fieldFilter>
			";
			var fieldFilterXml = new XmlDocument();
			fieldFilterXml.LoadXml(fieldFilterXmlString);

			this.SerializationFormatter = new YamlSerializationFormatter(doc, new ConfigurationFieldFilter(fieldFilterXml));
		}
コード例 #6
0
        public RainbowItemDeserializer()
        {
            // TODO: See if we can move this to a config file, rather than hard coding it here.
            const string xmlNodeString = @"
				<serializationFormatter type=""Rainbow.Storage.Yaml.YamlSerializationFormatter, Rainbow.Storage.Yaml"" singleInstance=""true"">
					<fieldFormatter type=""Rainbow.Formatting.FieldFormatters.MultilistFormatter, Rainbow"" />
                    <fieldFormatter type=""Rainbow.Formatting.FieldFormatters.XmlFieldFormatter, Rainbow"" />
                  </serializationFormatter >
			"            ;
            var          doc           = new XmlDocument();

            doc.LoadXml(xmlNodeString);

            // TODO: See if we can move this to a config file, rather than hard coding it here.
            const string fieldFilterXmlString = @"
				<fieldFilter type=""Rainbow.Filtering.ConfigurationFieldFilter, Rainbow"" singleInstance=""true"">
					<exclude fieldID=""{B1E16562-F3F9-4DDD-84CA-6E099950ECC0}"" note=""'Last run' field on Schedule template (used to register tasks)"" />
					<exclude fieldID=""{52807595-0F8F-4B20-8D2A-CB71D28C6103}"" note=""'__Owner' field on Standard Template"" />
					<exclude fieldID=""{F6D8A61C-2F84-4401-BD24-52D2068172BC}"" note=""'__Originator' field on Standard Template"" />
					<exclude fieldID=""{8CDC337E-A112-42FB-BBB4-4143751E123F}"" note=""'__Revision' field on Standard Template"" />
					<exclude fieldID=""{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}"" note=""'__Updated' field on Standard Template"" />
					<exclude fieldID=""{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}"" note=""'__Updated by' field on Standard Template"" />
					<exclude fieldID=""{001DD393-96C5-490B-924A-B0F25CD9EFD8}"" note=""'__Lock' field on Standard Template"" />
				</fieldFilter>
			"            ;
            var          fieldFilterXml       = new XmlDocument();

            fieldFilterXml.LoadXml(fieldFilterXmlString);

            this.SerializationFormatter = new YamlSerializationFormatter(doc, new ConfigurationFieldFilter(fieldFilterXml));
        }
コード例 #7
0
        public SerializationBlobStorageDataStore(
            string cloudRootPath,
            bool useDataCache,
            bool useBlobListCache,
            bool useBigFilesLazyLoad,
            string connectionString,
            string containerName,
            ITreeRootFactory rootFactory,
            ISerializationFormatter formatter)
        {
            Assert.ArgumentNotNullOrEmpty(cloudRootPath, nameof(cloudRootPath));
            Assert.ArgumentNotNull(formatter, nameof(formatter));
            Assert.ArgumentNotNull(rootFactory, nameof(rootFactory));

            this._connectionString          = connectionString;
            this._containerName             = containerName;
            this._useDataCache              = useDataCache;
            this._useBlobListCache          = useBlobListCache;
            this._useBigFilesLazyLoad       = useBigFilesLazyLoad;
            this._rootFactory               = rootFactory;
            this._formatter                 = formatter;
            this._formatter.ParentDataStore = this;

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            this.CloudRootPath = this.InitializeRootPath(cloudRootPath);

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            this.Trees = this.InitializeTrees(this._formatter, useDataCache, useBlobListCache, useBigFilesLazyLoad);
        }
コード例 #8
0
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ISerializationFormatter formatter)
 {
     _predicate          = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore    = sourceDataStore;
     _evaluator          = evaluator;
     _formatter          = formatter;
 }
コード例 #9
0
        // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
        protected virtual SerializationFileSystemTree CreateTree(TreeRoot root, ISerializationFormatter formatter,
                                                                 bool useDataCache)
        {
            var tree = new SerializationFileSystemTree(root.Name, root.Path, root.DatabaseName,
                                                       Path.Combine(PhysicalRootPath, root.Name), formatter, useDataCache);

            return(tree);
        }
コード例 #10
0
 public ConfigurationDetails(IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, IEvaluator evaluator, ISerializationFormatter formatter)
 {
     _predicate = predicate;
     _serializationStore = serializationStore;
     _sourceDataStore = sourceDataStore;
     _evaluator = evaluator;
     _formatter = formatter;
 }
コード例 #11
0
ファイル: WcfProxy.cs プロジェクト: eugene-h-lin/csla-svn
        private DataPortalResult GetResult(ISerializationFormatter formatter, WcfResponse response)
        {
            response = ConvertResponse(response);
            object            result        = formatter.Deserialize(response.ObjectData);
            ContextDictionary globalContext = (ContextDictionary)formatter.Deserialize(response.GlobalContext);
            DataPortalResult  returnValue   = new DataPortalResult(result, globalContext);

            return(returnValue);
        }
コード例 #12
0
        protected internal void CopyState(int parentEditLevel)
        {
            CopyingState();

            Type             currentType = this.GetType();
            HybridDictionary state       = new HybridDictionary();

            if (this.EditLevel + 1 > parentEditLevel)
            {
                throw new UndoException(string.Format(Resources.EditLevelMismatchException, "CopyState"));
            }

            do
            {
                // get the list of fields in this type
                List <DynamicMemberHandle> handlers =
                    UndoableHandler.GetCachedFieldHandlers(currentType);
                foreach (var h in handlers)
                {
                    var value = h.DynamicMemberGet(this);
                    if (typeof(YYT.Core.IUndoableObject).IsAssignableFrom(h.MemberType))
                    {
                        // make sure the variable has a value
                        if (value == null)
                        {
                            // variable has no value - store that fact
                            //state.Add(h.MemberFullName, null);
                            state.Add(h.MemberName, null);
                        }
                        else
                        {
                            // this is a child object, cascade the call
                            ((Core.IUndoableObject)value).CopyState(this.EditLevel + 1, BindingEdit);
                        }
                    }
                    else
                    {
                        // this is a normal field, simply trap the value
                        //state.Add(h.MemberFullName, value);
                        state.Add(h.MemberName, value);
                    }
                }

                currentType = currentType.BaseType;
            } while (currentType != typeof(UndoableBase));

            // serialize the state and stack it
            using (MemoryStream buffer = new MemoryStream())
            {
                ISerializationFormatter formatter =
                    SerializationFormatterFactory.GetFormatter();
                formatter.Serialize(buffer, state);
                _stateStack.Push(buffer.ToArray());
            }
            CopyStateComplete();
        }
コード例 #13
0
		protected override SerializationFileSystemTree CreateTree(TreeRoot root, ISerializationFormatter formatter, bool useDataCache)
		{
			var tree = new TfsSerializationFileSystemTree(root.Name, root.Path, root.DatabaseName, Path.Combine(PhysicalRootPath, root.Name), formatter, useDataCache);
			tree.TreeItemChanged += metadata =>
			{
				foreach (var watcher in ChangeWatchers) watcher(metadata, tree.DatabaseName);
			};

			return tree;
		}
コード例 #14
0
ファイル: ObjectCloner.cs プロジェクト: gnilesh4/csla
        /// <summary>
        /// Clones an object.
        /// </summary>
        /// <param name="obj">The object to clone.</param>
        /// <remarks>
        /// <para>The object to be cloned must be serializable.</para>
        /// <para>The serialization is performed using the formatter
        /// specified in ApplicationContext.</para>
        /// <para>The default is to use the MobileFormatter.</para>
        /// </remarks>
        public object Clone(object obj)
        {
            using var buffer = new MemoryStream();
            ISerializationFormatter formatter =
                SerializationFormatterFactory.GetFormatter(ApplicationContext);

            formatter.Serialize(buffer, obj);
            buffer.Position = 0;
            return(formatter.Deserialize(buffer));
        }
コード例 #15
0
        private List <SerializationFileSystemTree> InitTrees(ISerializationFormatter formatter, bool useDataCache)
        {
            var result = new List <SerializationFileSystemTree>();
            var roots  = _rootFactory.CreateTreeRoots();

            foreach (var root in roots)
            {
                result.Add(CreateTree(root, formatter, useDataCache));
            }

            return(result);
        }
コード例 #16
0
 /// <summary>
 /// Clones an object.
 /// </summary>
 /// <param name="obj">The object to clone.</param>
 /// <remarks>
 /// <para>The object to be cloned must be serializable.</para>
 /// <para>The serialization is performed using the formatter
 /// specified in the application's configuration file
 /// using the CslaSerializationFormatter key.</para>
 /// <para>The default is to use the
 /// <see cref="System.Runtime.Serialization.Formatters.Binary.BinaryFormatter" />
 /// </para>. You may also choose to use the Microsoft .NET 3.0
 /// <see cref="System.Runtime.Serialization.NetDataContractSerializer">
 /// NetDataContractSerializer</see> provided as part of WCF.
 /// </remarks>
 public static object Clone(object obj)
 {
     using (MemoryStream buffer = new MemoryStream())
     {
         ISerializationFormatter formatter =
             SerializationFormatterFactory.GetFormatter();
         formatter.Serialize(buffer, obj);
         buffer.Position = 0;
         object temp = formatter.Deserialize(buffer);
         return(temp);
     }
 }
コード例 #17
0
ファイル: WcfProxy.cs プロジェクト: eugene-h-lin/csla-svn
        private UpdateRequest GetRequest(ISerializationFormatter formatter, object obj, DataPortalContext context)
        {
            UpdateRequest request = new UpdateRequest();

            request.ClientContext   = formatter.Serialize(Csla.ApplicationContext.ClientContext);
            request.ClientCulture   = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
            request.ClientUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
            request.GlobalContext   = formatter.Serialize(Csla.ApplicationContext.GlobalContext);
            request.Principal       = formatter.Serialize(Csla.ApplicationContext.User);
            request.ObjectData      = formatter.Serialize(obj);
            request = ConvertRequest(request);
            return(request);
        }
コード例 #18
0
        // note: we pass in these params (formatter, datacache)
        // so that overriding classes may get access to private vars indirectly
        // (can't get at them otherwise because this is called from the constructor)
        protected virtual List <SerializationBlobStorageTree> InitializeTrees(ISerializationFormatter formatter,
                                                                              bool useDataCache, bool useBlobListCache, bool useBigFilesLazyLoad)
        {
            var result = new List <SerializationBlobStorageTree>();
            IEnumerable <TreeRoot> roots = this._rootFactory.CreateTreeRoots();

            foreach (TreeRoot root in roots)
            {
                result.Add(this.CreateTree(root, formatter, useDataCache, useBlobListCache, useBigFilesLazyLoad));
            }

            return(result);
        }
コード例 #19
0
ファイル: WcfProxy.cs プロジェクト: eugene-h-lin/csla-svn
        private CriteriaRequest GetRequest(ISerializationFormatter formatter, Type objectType, object criteria, DataPortalContext context)
        {
            CriteriaRequest request = new CriteriaRequest();

            request.ClientContext   = formatter.Serialize(Csla.ApplicationContext.ClientContext);
            request.ClientCulture   = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
            request.ClientUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
            request.CriteriaData    = formatter.Serialize(criteria);
            request.GlobalContext   = formatter.Serialize(Csla.ApplicationContext.GlobalContext);
            request.Principal       = formatter.Serialize(Csla.ApplicationContext.User);
            request.TypeName        = objectType.AssemblyQualifiedName;
            request = ConvertRequest(request);
            return(request);
        }
コード例 #20
0
        // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
        protected virtual SerializationFileSystemTree CreateTree(TreeRoot root, ISerializationFormatter formatter, bool useDataCache)
        {
            var tree = new SerializationFileSystemTree(root.Name, root.Path, root.DatabaseName, Path.Combine(PhysicalRootPath, root.Name), formatter, useDataCache);

            tree.TreeItemChanged += metadata =>
            {
                foreach (var watcher in ChangeWatchers)
                {
                    watcher(metadata, tree.DatabaseName);
                }
            };

            return(tree);
        }
コード例 #21
0
 public static object Deserialize(this ISerializationFormatter formatter, byte[] objectData)
 {
     if (objectData != null)
     {
         using (MemoryStream stream = new MemoryStream(objectData))
         {
             return(formatter.Deserialize(stream));
         }
     }
     else
     {
         return(null);
     }
 }
コード例 #22
0
 public static byte[] Serialize(this ISerializationFormatter formatter, object objectData)
 {
     if (objectData != null)
     {
         using (MemoryStream stream = new MemoryStream())
         {
             formatter.Serialize(stream, objectData);
             return(stream.GetBuffer());
         }
     }
     else
     {
         return(null);
     }
 }
コード例 #23
0
        public SerializationFileSystemDataStore(string physicalRootPath, bool useDataCache,
                                                ITreeRootFactory rootFactory, ISerializationFormatter formatter)
        {
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, nameof(physicalRootPath));
            Assert.ArgumentNotNull(formatter, nameof(formatter));
            Assert.ArgumentNotNull(rootFactory, nameof(rootFactory));

            _useDataCache = useDataCache;
            _rootFactory  = rootFactory;
            _formatter    = formatter;
            _formatter.ParentDataStore = this;

            PhysicalRootPath = InitRootPath(physicalRootPath);

            Trees = InitTrees(_formatter, useDataCache);
        }
コード例 #24
0
        // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
        protected virtual SerializationBlobStorageTree CreateTree(TreeRoot root, ISerializationFormatter formatter, bool useDataCache, bool useBlobListCache, bool useBigFilesLazyLoad)
        {
            var tree = new SerializationBlobStorageTree(
                root.Name,
                root.Path,
                root.DatabaseName,
                Path.Combine(this.CloudRootPath, root.Name),
                formatter,
                this._connectionString,
                this._containerName,
                useDataCache,
                useBlobListCache,
                useBigFilesLazyLoad);

            return(tree);
        }
コード例 #25
0
        public SerializationFileSystemDataStore(string physicalRootPath, bool useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter)
        {
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, "rootPath");
            Assert.ArgumentNotNull(formatter, "formatter");
            Assert.ArgumentNotNull(rootFactory, "rootFactory");

            _useDataCache = useDataCache;
            _rootFactory = rootFactory;
            _formatter = formatter;
            _formatter.ParentDataStore = this;

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            PhysicalRootPath = InitializeRootPath(physicalRootPath);

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            Trees = InitializeTrees(_formatter, useDataCache);
        }
コード例 #26
0
        public SerializationFileSystemDataStore(string physicalRootPath, bool useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter)
        {
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, nameof(physicalRootPath));
            Assert.ArgumentNotNull(formatter, nameof(formatter));
            Assert.ArgumentNotNull(rootFactory, nameof(rootFactory));

            _useDataCache = useDataCache;
            _rootFactory  = rootFactory;
            _formatter    = formatter;
            _formatter.ParentDataStore = this;

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            PhysicalRootPath = InitializeRootPath(physicalRootPath);

            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            Trees = InitializeTrees(_formatter, useDataCache);
        }
コード例 #27
0
        public AzureLazyItemData(
            IItemMetadata itemMetadata,
            string filePath,
            IAzureManager azureManager,
            ISerializationFormatter serializationFormatter)
        {
            Assert.ArgumentNotNull(itemMetadata, nameof(itemMetadata));
            Assert.ArgumentNotNull(azureManager, nameof(azureManager));
            Assert.ArgumentNotNull(filePath, nameof(filePath));
            Assert.ArgumentNotNull(serializationFormatter, nameof(serializationFormatter));

            this.itemMetadata           = itemMetadata;
            this.azureManager           = azureManager;
            this.filePath               = filePath;
            this.serializationFormatter = serializationFormatter;

            // ToDo: fix it - to do the lazy read, the context is needed to be preserved.
            if (serializationFormatter is YamlSerializationFormatter yamlSerializationFormatter)
            {
                this.parentDataStore = yamlSerializationFormatter.ParentDataStore;
            }

            this.itemDataLazy = new Lazy <IItemData>(this.LoadItemData, LazyThreadSafetyMode.ExecutionAndPublication);
        }
コード例 #28
0
        public SerializationBlobStorageTree(
            string name,
            string globalRootItemPath,
            string databaseName,
            string physicalRootPath,
            ISerializationFormatter formatter,
            string connectionString,
            string containerName,
            bool useDataCache,
            bool useBlobListCache,
            bool useBigFilesLazyLoad)
        {
            Assert.ArgumentNotNullOrEmpty(globalRootItemPath, nameof(globalRootItemPath));
            Assert.ArgumentNotNullOrEmpty(databaseName, nameof(databaseName));
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, nameof(physicalRootPath));
            Assert.ArgumentNotNull(formatter, nameof(formatter));
            Assert.IsTrue(globalRootItemPath.StartsWith("/"),
                          "The global root item path must start with '/', e.g. '/sitecore' or '/sitecore/content'");
            Assert.IsTrue(globalRootItemPath.Length > 1,
                          "The global root item path cannot be '/' - there is no root item. You probably mean '/sitecore'.");

            this._globalRootItemPath = globalRootItemPath.TrimEnd('/');

            this.AssertValidPhysicalPath(physicalRootPath);
            this._useBigFilesLazyLoad = useBigFilesLazyLoad;
            this._physicalRootPath    = physicalRootPath;
            this._azureManager        = new AzureManager(connectionString, containerName, physicalRootPath, useBlobListCache);
            this._formatter           = formatter;
            this._dataCache           = new AzureBlobCache <IItemData>(this._azureManager, useDataCache);
            this._metadataCache       = new AzureBlobCache <IItemMetadata>(this._azureManager, true);

            this.Name         = name;
            this.DatabaseName = databaseName;

            this._azureManager.EnsureDirectory(this._physicalRootPath);
        }
コード例 #29
0
ファイル: WcfProxy.cs プロジェクト: Jaans/csla
 private DataPortalResult GetResult(ISerializationFormatter formatter, WcfResponse response)
 {
   response = ConvertResponse(response);
   object result = formatter.Deserialize(response.ObjectData);
   ContextDictionary globalContext = (ContextDictionary)formatter.Deserialize(response.GlobalContext);
   DataPortalResult returnValue = new DataPortalResult(result, globalContext);
   return returnValue;
 }
コード例 #30
0
 // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
 protected virtual List<SerializationFileSystemTree> InitializeTrees(ISerializationFormatter formatter, bool useDataCache)
 {
     return _rootFactory.CreateTreeRoots().Select(tree => CreateTree(tree, formatter, useDataCache)).ToList();
 }
コード例 #31
0
ファイル: WcfProxy.cs プロジェクト: Jaans/csla
 private CriteriaRequest GetRequest(ISerializationFormatter formatter, Type objectType, object criteria, DataPortalContext context)
 {
   CriteriaRequest request = new CriteriaRequest();
   request.ClientContext = formatter.Serialize(Csla.ApplicationContext.ClientContext);
   request.ClientCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
   request.ClientUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
   request.CriteriaData = formatter.Serialize(criteria);
   request.GlobalContext = formatter.Serialize(Csla.ApplicationContext.GlobalContext);
   request.Principal = formatter.Serialize(Csla.ApplicationContext.User);
   request.TypeName = objectType.AssemblyQualifiedName;
   request = ConvertRequest(request);
   return request;
 }
コード例 #32
0
ファイル: WcfProxy.cs プロジェクト: Jaans/csla
 private UpdateRequest GetRequest(ISerializationFormatter formatter, object obj, DataPortalContext context)
 {
   UpdateRequest request = new UpdateRequest();
   request.ClientContext = formatter.Serialize(Csla.ApplicationContext.ClientContext);
   request.ClientCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
   request.ClientUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
   request.GlobalContext = formatter.Serialize(Csla.ApplicationContext.GlobalContext);
   request.Principal = formatter.Serialize(Csla.ApplicationContext.User);
   request.ObjectData = formatter.Serialize(obj);
   request = ConvertRequest(request);
   return request;
 }
コード例 #33
0
 // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
 protected virtual List <SerializationFileSystemTree> InitializeTrees(ISerializationFormatter formatter, bool useDataCache)
 {
     return(_rootFactory.CreateTreeRoots().Select(tree => CreateTree(tree, formatter, useDataCache)).ToList());
 }
コード例 #34
0
 public DilithiumSerializationFileSystemDataStore(string physicalRootPath, bool useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter) : base(physicalRootPath, useDataCache, rootFactory, formatter)
 {
 }
コード例 #35
0
		public TfsSerializationFileSystemTree(string name, string globalRootItemPath, string databaseName, string physicalRootPath, ISerializationFormatter formatter, bool useDataCache) : base(name, globalRootItemPath, databaseName, physicalRootPath, formatter, useDataCache)
		{
			_sourceControlManager = new SourceControlManager();
		}
コード例 #36
0
        protected internal void UndoChanges(int parentEditLevel)
        {
            UndoingChanges();

            // if we are a child object we might be asked to
            // undo below the level of stacked states,
            // so just do nothing in that case
            if (EditLevel > 0)
            {
                if (this.EditLevel - 1 != parentEditLevel)
                {
                    throw new UndoException(string.Format(Resources.EditLevelMismatchException, "UndoChanges"));
                }

                HybridDictionary state;
                using (MemoryStream buffer = new MemoryStream(_stateStack.Pop()))
                {
                    buffer.Position = 0;
                    ISerializationFormatter formatter =
                        SerializationFormatterFactory.GetFormatter();
                    state = (HybridDictionary)formatter.Deserialize(buffer);
                }

                Type currentType = this.GetType();

                do
                {
                    var currentTypeName = currentType.FullName;

                    // get the list of fields in this type
                    List <DynamicMemberHandle> handlers = UndoableHandler.GetCachedFieldHandlers(currentType);
                    foreach (var h in handlers)
                    {
                        // the field is undoable, so restore its value
                        var value = h.DynamicMemberGet(this);

                        if (typeof(Csla.Core.IUndoableObject).IsAssignableFrom(h.MemberType))
                        {
                            // this is a child object
                            // see if the previous value was empty
                            //if (state.Contains(h.MemberName))
                            if (state.Contains(GetFieldName(currentTypeName, h.MemberName)))
                            {
                                // previous value was empty - restore to empty
                                h.DynamicMemberSet(this, null);
                            }
                            else
                            {
                                // make sure the variable has a value
                                if (value != null)
                                {
                                    // this is a child object, cascade the call.
                                    ((Core.IUndoableObject)value).UndoChanges(this.EditLevel,
                                                                              BindingEdit);
                                }
                            }
                        }
                        else
                        {
                            // this is a regular field, restore its value
                            h.DynamicMemberSet(this, state[GetFieldName(currentTypeName, h.MemberName)]);
                            //h.DynamicMemberSet(this, state[h.MemberName]);
                        }
                    }

                    currentType = currentType.BaseType;
                } while (currentType != typeof(UndoableBase));
            }
            UndoChangesComplete();
        }
コード例 #37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name">A name for this tree, for your reference</param>
        /// <param name="globalRootItemPath">The 'global' path where this tree is rooted. For example, if this was '/sitecore/content', the root item in this tree would be 'content'</param>
        /// <param name="databaseName">Name of the database the items in this tree are from. This is for your reference and help when resolving this tree as a destination, and is not directly used.</param>
        /// <param name="physicalRootPath">The physical root path to write items in this tree to. Will be created if it does not exist.</param>
        /// <param name="formatter">The formatter to use when reading or writing items to disk</param>
        /// <param name="useDataCache">Whether to cache items read in memory for later rapid retrieval. Great for small trees, or if you have plenty of RAM. Bad for media trees :)</param>
        public SerializationFileSystemTree(string name, string globalRootItemPath, string databaseName, string physicalRootPath, ISerializationFormatter formatter, bool useDataCache)
        {
            Assert.ArgumentNotNullOrEmpty(globalRootItemPath, "globalRootItemPath");
            Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");
            Assert.ArgumentNotNullOrEmpty(physicalRootPath, "physicalRootPath");
            Assert.ArgumentNotNull(formatter, "formatter");
            Assert.IsTrue(globalRootItemPath.StartsWith("/"), "The global root item path must start with '/', e.g. '/sitecore' or '/sitecore/content'");
            Assert.IsTrue(globalRootItemPath.Length > 1, "The global root item path cannot be '/' - there is no root item. You probably mean '/sitecore'.");

            _globalRootItemPath = globalRootItemPath.TrimEnd('/');
            PhysicalRootPath = physicalRootPath;
            _formatter = formatter;
            _dataCache = new FsCache<IItemData>(useDataCache);
            Name = name;
            DatabaseName = databaseName;

            if (!Directory.Exists(PhysicalRootPath)) Directory.CreateDirectory(PhysicalRootPath);

            _treeWatcher = new TreeWatcher(PhysicalRootPath, _formatter.FileExtension, HandleDataItemChanged);
        }
コード例 #38
0
		public TfsSerializationFileSystemDataStore(string physicalRootPath, bool useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter) : base(physicalRootPath, useDataCache, rootFactory, formatter)
		{
			_sourceControlManager = new SourceControlManager();
		}
コード例 #39
0
 public TfsSerializationFileSystemDataStore(string physicalRootPath, bool useDataCache, ITreeRootFactory rootFactory, ISerializationFormatter formatter) : base(physicalRootPath, useDataCache, rootFactory, formatter)
 {
     _sourceControlManager = new SourceControlManager();
 }
コード例 #40
0
 public CommandService(Container container, ISerializationFormatter formatter)
 {
     _container = container;
     _formatter = formatter;
 }
コード例 #41
0
 // note: we pass in these params (formatter, datacache) so that overriding classes may get access to private vars indirectly (can't get at them otherwise because this is called from the constructor)
 protected virtual List <SerializationFileSystemTree> InitializeTrees(ISerializationFormatter formatter,
                                                                      bool useDataCache)
 {
     return(InitTrees(formatter, useDataCache));
 }