/// <summary>
        /// Gets CardDAV items.
        /// </summary>
        /// <param name="path">Relative path requested.</param>
        /// <param name="context">Instance of <see cref="DavContext"/> class.</param>
        /// <returns>Object implementing various business card items or null if no object corresponding to path is found.</returns>
        public static async Task <IHierarchyItemAsync> GetCardDavItemAsync(DavContext context, string path)
        {
            // If this is [DAVLocation]/addressbooks - return folder that contains all addressbooks.
            if (path.Equals(AddressbooksRootFolder.AddressbooksRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase))
            {
                return(new AddressbooksRootFolder(context));
            }

            string[] segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // If URL ends with .vcf - return address book file, which contains vCard.
            if (path.EndsWith(CardFile.Extension, System.StringComparison.InvariantCultureIgnoreCase))
            {
                string fileName = EncodeUtil.DecodeUrlPart(System.IO.Path.GetFileNameWithoutExtension(segments.Last()));
                return((await CardFile.LoadByFileNamesAsync(context, new[] { fileName }, PropsToLoad.All)).FirstOrDefault());
            }

            // If this is [DAVLocation]/addressbooks/[AddressbookFolderId]/ return address book.
            if (path.StartsWith(AddressbooksRootFolder.AddressbooksRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase))
            {
                Guid addressbookFolderId;
                if (Guid.TryParse(EncodeUtil.DecodeUrlPart(segments.Last()), out addressbookFolderId))

                {
                    return(await AddressbookFolder.LoadByIdAsync(context, addressbookFolderId));
                }
            }

            return(null);
        }
예제 #2
0
 public CDLLNumericRangeValueHintInfo(Dictionary <string, string> attr, CEncodedObjectInputBufferI bin) : base(NUMERIC_RANGE_VALUE_TYPE, attr, bin)
 {
     def_   = EncodeUtil.parseInt(attr[DEF_ATTR]);
     value_ = EncodeUtil.parseInt(attr[VALUE_ATTR]);
     min_   = EncodeUtil.parseInt(attr[MIN_ATTR]);
     max_   = EncodeUtil.parseInt(attr[MAX_ATTR]);
 }
예제 #3
0
        public COrder(CEncodedObjectInputBufferI bin)
        {
            bin.nextTag(TAG);

            Dictionary <string, string> A = bin.getAttributes();

            ordType_ = A[ORDTYPE];
            value_   = EncodeUtil.parseInt(A[VALUE]);
            if (A.ContainsKey(UTYPE))
            {
                utype_ = A[UTYPE];
            }
            flag_      = EncodeUtil.fromBoolString(A[FLAG]);
            ugid_      = EncodeUtil.parseUInt(A[UGID]);
            useEmbark_ = EncodeUtil.fromBoolString(A[UGID]);

            bin.firstChild();
            bin.nextTag(LOCS);
            if (bin.hasChildren())
            {
                bin.firstChild();
                locs_ = new List <CLoc>();
                while (!bin.reachedEndTag(LOCS))
                {
                    CLoc l = CLoc.fromKey(bin.getObjectText(LOC));
                    locs_.Add(l);
                }
            }
            bin.endTag(LOCS);


            bin.endTag(TAG);
        }
예제 #4
0
        /// <summary>
        /// Gets CalDAV items.
        /// </summary>
        /// <param name="itemPath">Relative path requested.</param>
        /// <param name="context">Instance of <see cref="DavContext"/> class.</param>
        /// <returns>Object implementing various calendar items or null if no object corresponding to path is found.</returns>
        public static async Task <IHierarchyItemAsync> GetCalDavItemAsync(DavContext context, string itemPath)
        {
            // If this is [DAVLocation]/calendars - return folder that contains all calendars.
            if (itemPath.Equals(CalendarsRootFolder.CalendarsRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase))
            {
                return(new CalendarsRootFolder(context));
            }

            string[] segments = itemPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            // If URL ends with .ics - return calendar file, which contains event or to-do.
            if (itemPath.EndsWith(CalendarFile.Extension, System.StringComparison.InvariantCultureIgnoreCase))
            {
                string uid = EncodeUtil.DecodeUrlPart(Path.GetFileNameWithoutExtension(segments.Last()));
                return((await CalendarFile.LoadByUidsAsync(context, new[] { uid }, PropsToLoad.All)).FirstOrDefault());
            }

            // If this is [DAVLocation]/calendars/[CalendarFolderId]/ return calendar.
            if (itemPath.StartsWith(CalendarsRootFolder.CalendarsRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase))
            {
                Guid calendarFolderId;
                if (Guid.TryParse(EncodeUtil.DecodeUrlPart(segments.Last()), out calendarFolderId))

                {
                    return(await CalendarFolder.LoadByIdAsync(context, calendarFolderId));
                }
            }

            return(null);
        }
        /// <summary>
        /// Called when this file is being copied.
        /// </summary>
        /// <param name="destFolder">Destination folder.</param>
        /// <param name="destName">New file name.</param>
        /// <param name="deep">Whether children items shall be copied. Ignored for files.</param>
        /// <param name="multistatus">Information about items that failed to copy.</param>
        public override async Task CopyToAsync(IItemCollectionAsync destFolder, string destName, bool deep, MultistatusException multistatus)
        {
            DavFolder targetFolder = (DavFolder)destFolder;

            if (!await context.DataLakeStoreService.ExistsAsync(targetFolder.Path))
            {
                throw new DavException("Target directory doesn't exist", DavStatus.CONFLICT);
            }

            string targetPath = targetFolder.Path + EncodeUtil.EncodeUrlPart(destName);

            // If an item with the same name exists - remove it.
            try
            {
                if (await context.GetHierarchyItemAsync(targetPath) is { } item)
                {
                    await item.DeleteAsync(multistatus);
                }
            }
            catch (DavException ex)
            {
                // Report exception to client and continue with other items by returning from recursion.
                multistatus.AddInnerException(targetPath, ex);
                return;
            }

            await context.DataLakeStoreService.CopyItemAsync(Path, targetFolder.Path, destName, ContentLength, dataCloudItem.Properties);

            await context.socketService.NotifyRefreshAsync(targetFolder.Path);
        }
        public override string getValue(string key)
        {
            string n = base.getValue(key);

            if (n != null)
            {
                return(n);
            }

            for (int i = 0; i < catkeys_.Count; i++)
            {
                if (catkeys_[i] == key)
                {
                    return(EncodeUtil.makeBoolString(i == currentOption_));
                }
            }


            foreach (List <CDLLHintInfo> hil in minfos_)
            {
                foreach (CDLLHintInfo hi in hil)
                {
                    n = hi.getValue(key);
                    if (n != null)
                    {
                        return(n);
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Called by Move It - decodes custom data records.
        /// Not specifically used by ABLC.
        /// </summary>
        /// <param name="record">String to decode</param>
        /// <param name="dataVersion">Data version</param>
        /// <returns>Decoded record</returns>
        public override object Decode64(string record, Version dataVersion)
        {
            // Safety check.
            if (record == null || record.Length == 0)
            {
                return(null);
            }

            // Generic xml encoding.
            XElement xml;

            using (StringReader input = new StringReader((string)EncodeUtil.BinaryDecode64(record)))
            {
                XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
                {
                    IgnoreWhitespace = true,
                    ProhibitDtd      = false,
                    XmlResolver      = null
                };
                using (XmlReader reader = XmlReader.Create(input, xmlReaderSettings))
                {
                    xml = XElement.Load(reader, LoadOptions.None);
                }
            }
            return(xml);
        }
예제 #8
0
 protected override void encodeAttr(CEncodedObjectOutputBufferI output)
 {
     base.encodeAttr(output);
     output.addAttr(NUM_CHILDREN, Convert.ToString(infos_.Count));
     output.addAttr(SIG_ATTR, Convert.ToString(sig_));
     output.addAttr(GO_ATTR, EncodeUtil.makeBoolString(goStraightToChildren_));
 }
예제 #9
0
        public CGameRules(CEncodedObjectInputBufferI bin)
        {
            bin.nextTag(TAG);
            Dictionary <string, string> A = bin.getAttributes();

            stackCount_          = EncodeUtil.parseUInt(A[STACK_COUNT]);
            useExploration_      = EncodeUtil.fromBoolString(A[EXPLORE]);
            useCityEff_          = EncodeUtil.fromBoolString(A[CITYEFF]);
            useContinue_         = EncodeUtil.fromBoolString(A[CONTINUE]);
            useSpec_             = EncodeUtil.fromBoolString(A[SPEC]);
            useDrain_            = EncodeUtil.fromBoolString(A[DRAIN]);
            useRoads_            = EncodeUtil.fromBoolString(A[ROADS]);
            useSupply_           = EncodeUtil.fromBoolString(A[SUPPLY]);
            useMines_            = EncodeUtil.fromBoolString(A[MINES]);
            useResources_        = EncodeUtil.fromBoolString(A[RESOURCES]);
            useNukes_            = EncodeUtil.fromBoolString(A[NUKES]);
            useDigin_            = EncodeUtil.fromBoolString(A[DIGIN]);
            useExperience_       = EncodeUtil.fromBoolString(A[EXPERIENCE]);
            useUnitNames_        = EncodeUtil.fromBoolString(A[UNITNAMES]);
            useDefFire_          = EncodeUtil.fromBoolString(A[DEFFIRE]);
            useRangeFire_        = EncodeUtil.fromBoolString(A[RANGEFIRE]);
            useCrippled_         = EncodeUtil.fromBoolString(A[CRIPPLED]);
            useUnitScrap_        = EncodeUtil.fromBoolString(A[SCRAP]);
            useDefTer_           = EncodeUtil.fromBoolString(A[DEFTER]);
            useHarshSupply_      = EncodeUtil.fromBoolString(A[HARSHSUPPLY]);
            useLimitedResources_ = EncodeUtil.fromBoolString(A[LIMITEDREOURCES]);
            bin.endTag(TAG);
        }
예제 #10
0
        /// <summary>
        /// Called when children of this folder are being listed.
        /// </summary>
        /// <param name="propNames">List of properties to retrieve with the children. They will be queried by the engine later.</param>
        /// <returns>Children of this folder.</returns>
        public virtual async Task <IEnumerable <IHierarchyItemAsync> > GetChildrenAsync(IList <PropertyName> propNames)
        {
            // Enumerates all child files and folders.
            // You can filter children items in this implementation and
            // return only items that you want to be visible for this
            // particular user.

            IList <IHierarchyItemAsync> children = new List <IHierarchyItemAsync>();

            FileSystemInfo[] fileInfos = null;
            fileInfos = dirInfo.GetFileSystemInfos();

            foreach (FileSystemInfo fileInfo in fileInfos)
            {
                string childPath          = Path + EncodeUtil.EncodeUrlPart(fileInfo.Name);
                IHierarchyItemAsync child = await context.GetHierarchyItemAsync(childPath);

                if (child != null)
                {
                    children.Add(child);
                }
            }

            return(children);
        }
예제 #11
0
 protected override void encodeAttr(CEncodedObjectOutputBufferI output)
 {
     base.encodeAttr(output);
     output.addAttr(NUM_CHILDREN, Convert.ToString(infos_.Count));
     output.addAttr(SIG_ATTR, Convert.ToString(sig_));
     output.addAttr(LOCKED_ATTR, EncodeUtil.makeBoolString(locked_));
 }
예제 #12
0
        /// <summary>
        /// Called when this folder is being moved or renamed.
        /// </summary>
        /// <param name="destFolder">Destination folder.</param>
        /// <param name="destName">New name of this folder.</param>
        /// <param name="multistatus">Information about child items that failed to move.</param>
        public override async Task MoveToAsync(IItemCollectionAsync destFolder, string destName, MultistatusException multistatus)
        {
            // in this function we move item by item, because we want to check if each item is not locked.
            if (!(destFolder is DavFolder))
            {
                throw new DavException("Target folder doesn't exist", DavStatus.CONFLICT);
            }

            DavFolder targetFolder = (DavFolder)destFolder;

            if (IsRecursive(targetFolder))
            {
                throw new DavException("Cannot move folder to its subtree.", DavStatus.FORBIDDEN);
            }

            string newDirPath = System.IO.Path.Combine(targetFolder.FullPath, destName);
            string targetPath = targetFolder.Path + EncodeUtil.EncodeUrlPart(destName);

            try
            {
                // Remove item with the same name at destination if it exists.
                IHierarchyItemAsync item = await context.GetHierarchyItemAsync(targetPath);

                if (item != null)
                {
                    await item.DeleteAsync(multistatus);
                }

                await targetFolder.CreateFolderAsync(destName);
            }
            catch (DavException ex)
            {
                // Continue the operation but report error with destination path to client.
                multistatus.AddInnerException(targetPath, ex);
                return;
            }

            // Move child items.
            bool         movedSuccessfully = true;
            IFolderAsync createdFolder     = (IFolderAsync)await context.GetHierarchyItemAsync(targetPath);

            foreach (DavHierarchyItem item in (await GetChildrenAsync(new PropertyName[0], null, null, new List <OrderProperty>())).Page)
            {
                try
                {
                    await item.MoveToAsync(createdFolder, item.Name, multistatus);
                }
                catch (DavException ex)
                {
                    // Continue the operation but report error with child item to client.
                    multistatus.AddInnerException(item.Path, ex);
                    movedSuccessfully = false;
                }
            }

            if (movedSuccessfully)
            {
                await DeleteAsync(multistatus);
            }
        }
예제 #13
0
        protected override void encodeAttr(CEncodedObjectOutputBufferI output)
        {
            base.encodeAttr(output);

            output.addAttr(DEF_ATTR, EncodeUtil.makeBoolString(def_));
            output.addAttr(VALUE_ATTR, EncodeUtil.makeBoolString(value_));
        }
예제 #14
0
        public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length)
        {
            int currentIndex = startIndex;

            // Response Fragment
            currentIndex = EncodeUtil.Decode(ref RequestMessageId, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref FailureCode, packetBytes, currentIndex);

            currentIndex = EncodeUtil.Decode(ref BubbleId, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref ParticipantId, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref AvatarId, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref BubbleName, packetBytes, currentIndex, 40);
            currentIndex = EncodeUtil.Decode(ref BubbleAssetCacheUrl, packetBytes, currentIndex, 50);
            currentIndex = EncodeUtil.Decode(ref BubbleRange, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref BubblePerceptionRange, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref BubbleRealTime, packetBytes, currentIndex);

            // Program Fragment
            currentIndex = EncodeUtil.Decode(ref ProgramName, packetBytes, currentIndex, 25);
            currentIndex = EncodeUtil.Decode(ref ProgramMajorVersion, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref ProgramMinorVersion, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref ProtocolMajorVersion, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref ProtocolMinorVersion, packetBytes, currentIndex);
            currentIndex = EncodeUtil.Decode(ref ProtocolSourceRevision, packetBytes, currentIndex);

            //FramesDecoded++;
            return(currentIndex);
        }
예제 #15
0
        public override int DecodeFragmentData(int frameIndex, byte[] packetBytes, int startIndex)
        {
            int currentIndex = startIndex;

            if (frameIndex == 0)
            {
                currentIndex = EncodeUtil.Decode(ref InteractionName, packetBytes, currentIndex, 20);
                currentIndex = EncodeUtil.Decode(ref SourceParticipantId, packetBytes, currentIndex);
                currentIndex = EncodeUtil.Decode(ref SourceObjectId, packetBytes, currentIndex);
                currentIndex = EncodeUtil.Decode(ref TargetParticipantId, packetBytes, currentIndex);
                currentIndex = EncodeUtil.Decode(ref TargetObjectId, packetBytes, currentIndex);

                currentIndex = EncodeUtil.Decode(ref ExtensionDialect, packetBytes, currentIndex, 4);
                currentIndex = EncodeUtil.Decode(ref ExtensionDialectMajorVersion, packetBytes, currentIndex);
                currentIndex = EncodeUtil.Decode(ref ExtensionDialectMinorVersion, packetBytes, currentIndex);
                currentIndex = EncodeUtil.Decode(ref extensionLength, packetBytes, currentIndex);

                SetExtensionData(new byte[extensionLength]);

                currentIndex = EncodeUtil.Decode(ref ExtensionData, 0, packetBytes, currentIndex, FragmentDataSize(frameIndex) - InternalDataPrefixSize);
            }
            else
            {
                currentIndex = EncodeUtil.Decode(ref ExtensionData, frameIndex * MxpConstants.MaxFrameDataSize - TotalDataPrefixSize, packetBytes, currentIndex, FragmentDataSize(frameIndex));
            }

            return(currentIndex);
        }
예제 #16
0
        public override object Decode64(string record, Version dataVersion)
        {
            if (record == null || record.Length == 0)
            {
                return(null);
            }

            // XElement.Parse throws MissingMethodException
            // Method not found: System.Xml.XmlReaderSettings.set_MaxCharactersFromEntities
            XElement xml;

            using (StringReader input = new StringReader((string)EncodeUtil.BinaryDecode64(record)))
            {
                XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
                {
                    IgnoreWhitespace = true,
                    ProhibitDtd      = false,
                    XmlResolver      = null
                };
                using (XmlReader reader = XmlReader.Create(input, xmlReaderSettings))
                {
                    xml = XElement.Load(reader, LoadOptions.None);
                }
            }
            return(xml);
        }
예제 #17
0
        public void encode(CEncodedObjectOutputBufferI output)
        {
            output.openObject(TAG);
            output.addAttr(ORDTYPE, ordType_);
            output.addAttr(VALUE, Convert.ToString(value_));
            if (utype_ != null)
            {
                output.addAttr(UTYPE, utype_);
            }
            output.addAttr(FLAG, EncodeUtil.makeBoolString(flag_));
            output.addAttr(UGID, Convert.ToString(ugid_));
            output.addAttr(USEEMBARK, EncodeUtil.makeBoolString(useEmbark_));

            output.openObject(LOCS);
            if (locs_ != null)
            {
                foreach (CLoc l in locs_)
                {
                    output.addTextObject(LOC, l.getKey());
                }
            }
            output.objectEnd();


            output.objectEnd();
        }
예제 #18
0
        public void encode(CEncodedObjectOutputBufferI output)
        {
            output.openObject(TAG);
            output.addAttr(ORIGINAL_POSITION, Convert.ToString(originalPosition_));
            output.addAttr(POSITION, Convert.ToString(position_));
            output.addAttr(BUYPOINTS, Convert.ToString(buypoints_));
            output.addAttr(BUYPOINTSSPENT, Convert.ToString(buypointsSpent_));
            output.addAttr(SCORE, Convert.ToString(score_));
            output.addAttr(PCAP, Convert.ToString(pcap_));
            output.addAttr(CCAP, Convert.ToString(ccap_));
            output.addAttr(NCAP, Convert.ToString(ncap_));
            output.addAttr(LIVING, EncodeUtil.makeBoolString(living_));

            output.addTextObject(TYPE_TAG, type_);
            if (pname_ != null)
            {
                output.addTextObject(PNAME_TAG, pname_);
            }
            if (deadReason_ != null)
            {
                output.addTextObject(DEAD_REASON_TAG, deadReason_);
            }

            output.objectEnd();
        }
예제 #19
0
        public CPlayer(CEncodedObjectInputBufferI bin)
        {
            bin.nextTag(TAG);
            Dictionary <string, string> A = bin.getAttributes();

            originalPosition_ = EncodeUtil.parseInt(A[ORIGINAL_POSITION]);
            position_         = EncodeUtil.parseInt(A[POSITION]);
            buypoints_        = EncodeUtil.parseInt(A[BUYPOINTS]);
            buypointsSpent_   = EncodeUtil.parseInt(A[BUYPOINTSSPENT]);
            score_            = EncodeUtil.parseInt(A[SCORE]);
            pcap_             = EncodeUtil.parseInt(A[PCAP]);
            ccap_             = EncodeUtil.parseInt(A[CCAP]);
            ncap_             = EncodeUtil.parseInt(A[NCAP]);
            living_           = EncodeUtil.fromBoolString(A[LIVING]);

            type_ = bin.getObjectText(TYPE_TAG);
            if (bin.thisTag() == PNAME_TAG)
            {
                pname_ = bin.getObjectText(PNAME_TAG);
            }
            else
            {
                pname_ = null;
            }
            if (bin.thisTag() == DEAD_REASON_TAG)
            {
                deadReason_ = bin.getObjectText(DEAD_REASON_TAG);
            }
            else
            {
                deadReason_ = null;
            }

            bin.endTag(TAG);
        }
예제 #20
0
 public void encode(CEncodedObjectOutputBufferI output)
 {
     output.openObject(TAG);
     output.addAttr(STACK_COUNT, Convert.ToString(stackCount_));
     output.addAttr(EXPLORE, EncodeUtil.makeBoolString(useExploration_));
     output.addAttr(CITYEFF, EncodeUtil.makeBoolString(useCityEff_));
     output.addAttr(CONTINUE, EncodeUtil.makeBoolString(useContinue_));
     output.addAttr(SPEC, EncodeUtil.makeBoolString(useSpec_));
     output.addAttr(DRAIN, EncodeUtil.makeBoolString(useDrain_));
     output.addAttr(ROADS, EncodeUtil.makeBoolString(useRoads_));
     output.addAttr(SUPPLY, EncodeUtil.makeBoolString(useSupply_));
     output.addAttr(MINES, EncodeUtil.makeBoolString(useMines_));
     output.addAttr(RESOURCES, EncodeUtil.makeBoolString(useResources_));
     output.addAttr(NUKES, EncodeUtil.makeBoolString(useNukes_));
     output.addAttr(DIGIN, EncodeUtil.makeBoolString(useDigin_));
     output.addAttr(EXPERIENCE, EncodeUtil.makeBoolString(useExperience_));
     output.addAttr(UNITNAMES, EncodeUtil.makeBoolString(useUnitNames_));
     output.addAttr(DEFFIRE, EncodeUtil.makeBoolString(useDefFire_));
     output.addAttr(RANGEFIRE, EncodeUtil.makeBoolString(useRangeFire_));
     output.addAttr(CRIPPLED, EncodeUtil.makeBoolString(useCrippled_));
     output.addAttr(SCRAP, EncodeUtil.makeBoolString(useUnitScrap_));
     output.addAttr(DEFTER, EncodeUtil.makeBoolString(useDefTer_));
     output.addAttr(HARSHSUPPLY, EncodeUtil.makeBoolString(useHarshSupply_));
     output.addAttr(LIMITEDREOURCES, EncodeUtil.makeBoolString(useLimitedResources_));
     output.objectEnd();
 }
예제 #21
0
        public VlasovPlayer(
            int position,
            Dictionary <string, string> caMap,
            CEncodedObjectInputBufferI bin,
            string logpath,
            string logname,
            AIEventInterfaceI aiEvent,
            AICommandInterfaceI command,
            AIQueryI query,
            AICheatI cheat,
            int logLevel)
            : base(
                position,
                logpath,
                logname,
                caMap,
                bin,
                aiEvent,
                command,
                query,
                cheat,
                logLevel)
        {
            elogger_ = new CSubLog("ExamplePlayer:" + Convert.ToString(position), realLog_);
            elogger_.info("D Logger Log Open: " + logpath + " " + logname);
            elogger_.info("Position " + Convert.ToSingle(position) + " waking up.");

            testAttribute_ = EncodeUtil.parseInt(caMap[TEST_ATTR]);

            hints_ = new CDLLHints(bin);
        }
예제 #22
0
 /// <summary>
 /// Returns the physical file path that corresponds to the specified virtual path on the Web server.
 /// </summary>
 /// <param name="relativePath">Path relative to WebDAV root folder.</param>
 /// <returns>Corresponding path in file system.</returns>
 internal string MapPath(string relativePath)
 {
     //Convert to local file system path by decoding every part, reversing slashes and appending
     //to repository root.
     string[] encodedParts = relativePath.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
     string[] decodedParts = encodedParts.Select <string, string>(p => EncodeUtil.DecodeUrlPart(p).Normalize(NormalizationForm.FormC)).ToArray();
     return(Path.Combine(RepositoryPath, string.Join(Path.DirectorySeparatorChar.ToString(), decodedParts)));
 }
예제 #23
0
파일: CLoc.cs 프로젝트: OlegYurchik/edce-ai
        public static CLoc fromKey(string k)
        {
            int    si = k.IndexOf("_", StringComparison.Ordinal);
            string sx = k.Substring(0, si);
            string sy = k.Substring(si + 1);

            return(new CLoc(EncodeUtil.parseInt(sx), EncodeUtil.parseInt(sy)));
        }
예제 #24
0
        public override int EncodeFrameData(int frameIndex, byte[] packetBytes, int startIndex)
        {
            int currentIndex = startIndex;

            currentIndex = EncodeUtil.Encode(ref ChallengeRequestBytes, packetBytes, currentIndex, 64);
            //FramesEncoded++;
            return(currentIndex);
        }
예제 #25
0
 public override string Encode64(object record)
 {
     if (record == null)
     {
         return(null);
     }
     return(EncodeUtil.BinaryEncode64(record.ToString()));
 }
예제 #26
0
        public override int DecodeFrameData(int frameIndex, byte[] packetBytes, int startIndex, int length)
        {
            int currentIndex = startIndex;

            currentIndex = EncodeUtil.Decode(ref ListType, packetBytes, currentIndex);
            //FramesDecoded++;
            return(currentIndex);
        }
예제 #27
0
        public override int EncodeFrameData(int frameIndex, byte[] packetBytes, int startIndex)
        {
            int currentIndex = startIndex;

            currentIndex = EncodeUtil.Encode(ref BytesPerSecond, packetBytes, currentIndex);
            //FramesEncoded++;
            return(currentIndex);
        }
예제 #28
0
        public void DecodeUnicodeTest()
        {
            string expected = "验证此测试方法的正确性。";
            string str      = EncodeUtil.EncodeUnicode(expected);
            string actual;

            actual = EncodeUtil.DecodeUnicode(str);
            Assert.AreEqual(expected, actual);
        }
예제 #29
0
 /// <summary>
 /// Creates instance of User class.
 /// </summary>
 /// <param name="context">Instance of <see cref="DavContext"/> class.</param>
 /// <param name="userId">ID of this user</param>
 /// <param name="name">User name.</param>
 /// <param name="email">User e-mail.</param>
 /// <param name="created">Date when this item was created.</param>
 /// <param name="modified">Date when this item was modified.</param>
 public User(DavContext context, string userId, string name, string email, DateTime created, DateTime modified)
     : base(context)
 {
     this.Name     = name;
     this.email    = email;
     this.Path     = UsersFolder.UsersFolderPath + EncodeUtil.EncodeUrlPart(userId);
     this.Created  = created;
     this.Modified = modified;
 }
예제 #30
0
        /// <summary>
        /// Called when this file is being moved or renamed.
        /// </summary>
        /// <param name="destFolder">Destination folder.</param>
        /// <param name="destName">New name of this file.</param>
        /// <param name="multistatus">Information about items that failed to move.</param>
        public override async Task MoveToAsync(IItemCollectionAsync destFolder, string destName, MultistatusException multistatus)
        {
            DavFolder targetFolder = (DavFolder)destFolder;

            if (targetFolder == null || !Directory.Exists(targetFolder.FullPath))
            {
                throw new DavException("Target directory doesn't exist", DavStatus.CONFLICT);
            }

            string newDirPath = System.IO.Path.Combine(targetFolder.FullPath, destName);
            string targetPath = targetFolder.Path + EncodeUtil.EncodeUrlPart(destName);

            // If an item with the same name exists in target directory - remove it.
            try
            {
                IHierarchyItemAsync item = await context.GetHierarchyItemAsync(targetPath);

                if (item != null)
                {
                    await item.DeleteAsync(multistatus);
                }
            }
            catch (DavException ex)
            {
                // Report exception to client and continue with other items by returning from recursion.
                multistatus.AddInnerException(targetPath, ex);
                return;
            }

            // Move the file.
            try
            {
                File.Move(fileSystemInfo.FullName, newDirPath);

                var newFileInfo = new FileInfo(newDirPath);
                if (FileSystemInfoExtension.IsUsingFileSystemAttribute)
                {
                    await fileSystemInfo.MoveExtendedAttributes(newFileInfo);
                }

                // Locks should not be copied, delete them.
                if (await newFileInfo.HasExtendedAttributeAsync("Locks"))
                {
                    await newFileInfo.DeleteExtendedAttributeAsync("Locks");
                }
            }
            catch (UnauthorizedAccessException)
            {
                // Exception occurred with the item for which MoveTo was called - fail the operation.
                NeedPrivilegesException ex = new NeedPrivilegesException("Not enough privileges");
                ex.AddRequiredPrivilege(targetPath, Privilege.Bind);

                string parentPath = System.IO.Path.GetDirectoryName(Path);
                ex.AddRequiredPrivilege(parentPath, Privilege.Unbind);
                throw ex;
            }
        }
예제 #31
0
 public void Test1()
 {
     string encode = "<img src=\"http://www.iplcricketnow.com/wp-content/uploads/2011/04/Lasith_Malinga.jpg\" id=\"il_fi\" height=\"360\" width=\"300\" style=\"padding-right: 8px; padding-top: 8px; padding-bottom: 8px; \">";
     EncodeUtil encodeUtil = new EncodeUtil();
     string encodeResult = encodeUtil.HtmlEncode(encode);
 }
예제 #32
0
 public void Test2()
 {
     string encode = "<script>alert('Hi');</script>";
     EncodeUtil encodeUtil = new EncodeUtil();
     string encodeResult = encodeUtil.HtmlEncode(encode);
 }
예제 #33
0
 public void Test3()
 {
     string encode = "<script>window.location='www.google.com.sg'</script>";
     EncodeUtil encodeUtil = new EncodeUtil();
     string encodeResult = encodeUtil.HtmlEncode(encode);
 }
예제 #34
0
 public void Test4()
 {
     EncodeUtil encodeUtil = new EncodeUtil();
     string encodeResult = encodeUtil.HtmlEncode(null);
 }
예제 #35
0
 public void Test5()
 {
     EncodeUtil encodeUtil = new EncodeUtil();
     string encodeResult = encodeUtil.HtmlEncode(string.Empty);
 }