示例#1
0
        public DfsContext(IDfsConfiguration dfsConfiguration)
        {
            this.dfsConfiguration = dfsConfiguration;
            serviceFactory = ServiceFactory.Instance;

            var contextFactory = ContextFactory.Instance;
            serviceContext = contextFactory.NewContext();

            var repositoryIdentity = new RepositoryIdentity(dfsConfiguration.Repository, dfsConfiguration.UserName, dfsConfiguration.Password, string.Empty);
            serviceContext.AddIdentity(repositoryIdentity);

            var contentTransferProfile = new ContentTransferProfile
            {
                TransferMode = ContentTransferMode.MTOM
            };
            serviceContext.SetProfile(contentTransferProfile);

            // Setting the filter to ALL can cause errors if the DataObject
            // passed to the operation contains system properties, so to be safe 
            // set the filter to ALL_NON_SYSTEM unless you explicitly want to update
            // a system property
            var propertyProfile = new PropertyProfile
            {
                FilterMode = PropertyFilterMode.ALL_NON_SYSTEM
            };
            serviceContext.SetProfile(propertyProfile);

            serviceContext.SetRuntimeProperty("USER_TRANSACTION_HINT", "TRANSACTION_REQUIRED");
        }