private void HandleSearchFlag(string input) { int max = GetMaxSearchNumber(); switch (input) { case "-safesearch_active": this.SafeSearch = SafeEnum.Active; break; case "-safesearch_off": this.SafeSearch = SafeEnum.Off; break; default: if (input.Contains(this.flags[2])) { if (int.TryParse(input.Split('_')[1], out int number) && (number <= max) && (number >= 1)) { this.SearchNumber = number; return; } } break; } }
//[ExpectedException(typeof(TypeInitializationException))] public void TestSafeEnum_ConstructionError() { VoatAssert.Throws <TypeInitializationException>(() => { var s = new SomeStruct(); SafeEnum <SomeStruct> x = new SafeEnum <SomeStruct>(s); }); }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as Folder; if(typedSource != null) { FileCount = typedSource.FileCount; Children = typedSource.Children; HasRemoteChildren = typedSource.HasRemoteChildren; Info = typedSource.Info; Redirection = typedSource.Redirection; FavoriteFolder = typedSource.FavoriteFolder; ZoneService = typedSource.ZoneService; } else { JToken token; if(source.TryGetProperty("FileCount", out token) && token.Type != JTokenType.Null) { FileCount = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("Children", out token) && token.Type != JTokenType.Null) { Children = (IEnumerable<Item>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<Item>)); } if(source.TryGetProperty("HasRemoteChildren", out token) && token.Type != JTokenType.Null) { HasRemoteChildren = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("Info", out token) && token.Type != JTokenType.Null) { Info = (ItemInfo)serializer.Deserialize(token.CreateReader(), typeof(ItemInfo)); } if(source.TryGetProperty("Redirection", out token) && token.Type != JTokenType.Null) { Redirection = (Redirection)serializer.Deserialize(token.CreateReader(), typeof(Redirection)); } if(source.TryGetProperty("FavoriteFolder", out token) && token.Type != JTokenType.Null) { FavoriteFolder = (FavoriteFolder)serializer.Deserialize(token.CreateReader(), typeof(FavoriteFolder)); } if(source.TryGetProperty("ZoneService", out token) && token.Type != JTokenType.Null) { ZoneService = (SafeEnum<ZoneService>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<ZoneService>)); } } }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as ItemDlpInfo; if(typedSource != null) { Status = typedSource.Status; } else { JToken token; if(source.TryGetProperty("Status", out token) && token.Type != JTokenType.Null) { Status = (SafeEnum<DlpStatus>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<DlpStatus>)); } } }
public async Task Say(params string[] args) { try { bool result = await CheckGoogleConfig(); if (!result) { return; // Google Config is not valid/supplied } CustomsearchService service = new CustomsearchService(new BaseClientService.Initializer { ApiKey = Program.config.GoogleApiKey }); SafeSearch = GetSafeSearchVal(); //Tries to grab from json settings or uses hardcoded value SearchNumber = 1; //Default value number of results to return string output = ""; var search = HandleSearchRequest(service, args); output = FormatResultOutput(search, output); if (output.Trim().Length == 0) { await Context.Channel.SendMessageAsync("No Search Results Found."); return; } await Context.Channel.SendMessageAsync(output); } catch (Exception e) { await Program.Instance.Log(new Discord.LogMessage(Discord.LogSeverity.Verbose, "SearchCMD", e.Message)); await Context.Channel.SendMessageAsync(e.Message); } }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as PreviewPlatformInfo; if(typedSource != null) { PreviewPlatform = typedSource.PreviewPlatform; ItemProtocolLink = typedSource.ItemProtocolLink; } else { JToken token; if(source.TryGetProperty("PreviewPlatform", out token) && token.Type != JTokenType.Null) { PreviewPlatform = (SafeEnum<PreviewPlatform>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<PreviewPlatform>)); } if(source.TryGetProperty("ItemProtocolLink", out token) && token.Type != JTokenType.Null) { ItemProtocolLink = (ItemProtocolLink)serializer.Deserialize(token.CreateReader(), typeof(ItemProtocolLink)); } } }
public async Task Say(params string[] args) { if (!Program.HasMember(Program.config, "GoogleApiKey") || !Program.HasMember(Program.config, "GoogleSearchEngineID")) { await Context.Channel.SendMessageAsync("This command must have a valid Google API key! Please contact the owner."); return; } if (args.Length == 0) { await Context.Channel.SendMessageAsync("No input given!"); return; } CustomsearchService service = new CustomsearchService(new BaseClientService.Initializer { ApiKey = Program.config.GoogleApiKey }); SafeSearch = GetSafeSearchVal(); //Tries to grab from json settings or uses hardcoded value SearchNumber = 1; //Default value number of results to return string output = ""; var search = HandleSearchRequest(service, args); output = FormatResultOutput(search, output); if (output.Trim().Length == 0) { await Context.Channel.SendMessageAsync("No Search Results Found."); return; } await Context.Channel.SendMessageAsync(output); }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as Account; if(typedSource != null) { CompanyName = typedSource.CompanyName; BillingContact = typedSource.BillingContact; BillingContactId = typedSource.BillingContactId; TechnicalContact = typedSource.TechnicalContact; TechnicalContactId = typedSource.TechnicalContactId; AccountManager = typedSource.AccountManager; AccountManagerId = typedSource.AccountManagerId; AccountType = typedSource.AccountType; PlanName = typedSource.PlanName; PlanTrack = typedSource.PlanTrack; PlanTrackEnum = typedSource.PlanTrackEnum; BillingType = typedSource.BillingType; BillingCycle = typedSource.BillingCycle; BillingRate = typedSource.BillingRate; BaseBillingRate = typedSource.BaseBillingRate; BaseBandwidth = typedSource.BaseBandwidth; BaseDiskSpace = typedSource.BaseDiskSpace; BaseUsers = typedSource.BaseUsers; AdditionalBandwidth = typedSource.AdditionalBandwidth; AdditionalDiskSpace = typedSource.AdditionalDiskSpace; AdditionalUsers = typedSource.AdditionalUsers; AdditionalBandwidthRate = typedSource.AdditionalBandwidthRate; AdditionalDiskSpaceRate = typedSource.AdditionalDiskSpaceRate; AdditionalUserRate = typedSource.AdditionalUserRate; UserMax = typedSource.UserMax; UserUsage = typedSource.UserUsage; DiskSpaceMax = typedSource.DiskSpaceMax; DiskSpace = typedSource.DiskSpace; BandwidthMax = typedSource.BandwidthMax; HasPowerTools = typedSource.HasPowerTools; HasEncryption = typedSource.HasEncryption; PowerToolsRate = typedSource.PowerToolsRate; EncryptionRate = typedSource.EncryptionRate; Address1 = typedSource.Address1; Address2 = typedSource.Address2; City = typedSource.City; State = typedSource.State; Zip = typedSource.Zip; Country = typedSource.Country; CreditCardType = typedSource.CreditCardType; CreditCardNumber = typedSource.CreditCardNumber; CreditCardExpirationMonth = typedSource.CreditCardExpirationMonth; CreditCardExpirationYear = typedSource.CreditCardExpirationYear; CreditCardFirstName = typedSource.CreditCardFirstName; CreditCardLastName = typedSource.CreditCardLastName; Phone = typedSource.Phone; LastBillingDate = typedSource.LastBillingDate; NextBillingDate = typedSource.NextBillingDate; UseAdvancedCustomBranding = typedSource.UseAdvancedCustomBranding; AdvancedCustomBrandingFolderName = typedSource.AdvancedCustomBrandingFolderName; BrandingStyles = typedSource.BrandingStyles; LogoURL = typedSource.LogoURL; RootItem = typedSource.RootItem; RootItemId = typedSource.RootItemId; CreationDate = typedSource.CreationDate; IsFreeTrial = typedSource.IsFreeTrial; IsCancelled = typedSource.IsCancelled; CancellationDate = typedSource.CancellationDate; SSO = typedSource.SSO; Preferences = typedSource.Preferences; ProductDefaults = typedSource.ProductDefaults; Subdomain = typedSource.Subdomain; Subdomains = typedSource.Subdomains; MobileSecuritySettings = typedSource.MobileSecuritySettings; LoginAccessControlDomains = typedSource.LoginAccessControlDomains; FolderAccessControlDomains = typedSource.FolderAccessControlDomains; StorageQuotaPerUser = typedSource.StorageQuotaPerUser; FreeTrialId = typedSource.FreeTrialId; Source = typedSource.Source; AttributedSource = typedSource.AttributedSource; CompanyURL = typedSource.CompanyURL; MarketingOptIn = typedSource.MarketingOptIn; CreditCardSecurityCode = typedSource.CreditCardSecurityCode; ToolInformation = typedSource.ToolInformation; BillingInformation = typedSource.BillingInformation; AccountSubType = typedSource.AccountSubType; } else { JToken token; if(source.TryGetProperty("CompanyName", out token) && token.Type != JTokenType.Null) { CompanyName = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("BillingContact", out token) && token.Type != JTokenType.Null) { BillingContact = (User)serializer.Deserialize(token.CreateReader(), typeof(User)); } if(source.TryGetProperty("BillingContactId", out token) && token.Type != JTokenType.Null) { BillingContactId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("TechnicalContact", out token) && token.Type != JTokenType.Null) { TechnicalContact = (User)serializer.Deserialize(token.CreateReader(), typeof(User)); } if(source.TryGetProperty("TechnicalContactId", out token) && token.Type != JTokenType.Null) { TechnicalContactId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("AccountManager", out token) && token.Type != JTokenType.Null) { AccountManager = (User)serializer.Deserialize(token.CreateReader(), typeof(User)); } if(source.TryGetProperty("AccountManagerId", out token) && token.Type != JTokenType.Null) { AccountManagerId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("AccountType", out token) && token.Type != JTokenType.Null) { AccountType = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("PlanName", out token) && token.Type != JTokenType.Null) { PlanName = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("PlanTrack", out token) && token.Type != JTokenType.Null) { PlanTrack = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("PlanTrackEnum", out token) && token.Type != JTokenType.Null) { PlanTrackEnum = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("BillingType", out token) && token.Type != JTokenType.Null) { BillingType = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("BillingCycle", out token) && token.Type != JTokenType.Null) { BillingCycle = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("BillingRate", out token) && token.Type != JTokenType.Null) { BillingRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("BaseBillingRate", out token) && token.Type != JTokenType.Null) { BaseBillingRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("BaseBandwidth", out token) && token.Type != JTokenType.Null) { BaseBandwidth = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("BaseDiskSpace", out token) && token.Type != JTokenType.Null) { BaseDiskSpace = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("BaseUsers", out token) && token.Type != JTokenType.Null) { BaseUsers = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("AdditionalBandwidth", out token) && token.Type != JTokenType.Null) { AdditionalBandwidth = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("AdditionalDiskSpace", out token) && token.Type != JTokenType.Null) { AdditionalDiskSpace = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("AdditionalUsers", out token) && token.Type != JTokenType.Null) { AdditionalUsers = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("AdditionalBandwidthRate", out token) && token.Type != JTokenType.Null) { AdditionalBandwidthRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("AdditionalDiskSpaceRate", out token) && token.Type != JTokenType.Null) { AdditionalDiskSpaceRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("AdditionalUserRate", out token) && token.Type != JTokenType.Null) { AdditionalUserRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("UserMax", out token) && token.Type != JTokenType.Null) { UserMax = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("UserUsage", out token) && token.Type != JTokenType.Null) { UserUsage = (UserUsage)serializer.Deserialize(token.CreateReader(), typeof(UserUsage)); } if(source.TryGetProperty("DiskSpaceMax", out token) && token.Type != JTokenType.Null) { DiskSpaceMax = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("DiskSpace", out token) && token.Type != JTokenType.Null) { DiskSpace = (DiskSpace)serializer.Deserialize(token.CreateReader(), typeof(DiskSpace)); } if(source.TryGetProperty("BandwidthMax", out token) && token.Type != JTokenType.Null) { BandwidthMax = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("HasPowerTools", out token) && token.Type != JTokenType.Null) { HasPowerTools = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("HasEncryption", out token) && token.Type != JTokenType.Null) { HasEncryption = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("PowerToolsRate", out token) && token.Type != JTokenType.Null) { PowerToolsRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("EncryptionRate", out token) && token.Type != JTokenType.Null) { EncryptionRate = (decimal?)serializer.Deserialize(token.CreateReader(), typeof(decimal?)); } if(source.TryGetProperty("Address1", out token) && token.Type != JTokenType.Null) { Address1 = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Address2", out token) && token.Type != JTokenType.Null) { Address2 = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("City", out token) && token.Type != JTokenType.Null) { City = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("State", out token) && token.Type != JTokenType.Null) { State = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Zip", out token) && token.Type != JTokenType.Null) { Zip = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Country", out token) && token.Type != JTokenType.Null) { Country = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardType", out token) && token.Type != JTokenType.Null) { CreditCardType = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardNumber", out token) && token.Type != JTokenType.Null) { CreditCardNumber = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardExpirationMonth", out token) && token.Type != JTokenType.Null) { CreditCardExpirationMonth = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardExpirationYear", out token) && token.Type != JTokenType.Null) { CreditCardExpirationYear = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardFirstName", out token) && token.Type != JTokenType.Null) { CreditCardFirstName = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreditCardLastName", out token) && token.Type != JTokenType.Null) { CreditCardLastName = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Phone", out token) && token.Type != JTokenType.Null) { Phone = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("LastBillingDate", out token) && token.Type != JTokenType.Null) { LastBillingDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?)); } if(source.TryGetProperty("NextBillingDate", out token) && token.Type != JTokenType.Null) { NextBillingDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?)); } if(source.TryGetProperty("UseAdvancedCustomBranding", out token) && token.Type != JTokenType.Null) { UseAdvancedCustomBranding = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("AdvancedCustomBrandingFolderName", out token) && token.Type != JTokenType.Null) { AdvancedCustomBrandingFolderName = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("BrandingStyles", out token) && token.Type != JTokenType.Null) { BrandingStyles = (IDictionary<string, string>)serializer.Deserialize(token.CreateReader(), typeof(IDictionary<string, string>)); } if(source.TryGetProperty("LogoURL", out token) && token.Type != JTokenType.Null) { LogoURL = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("RootItem", out token) && token.Type != JTokenType.Null) { RootItem = (Item)serializer.Deserialize(token.CreateReader(), typeof(Item)); } if(source.TryGetProperty("RootItemId", out token) && token.Type != JTokenType.Null) { RootItemId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CreationDate", out token) && token.Type != JTokenType.Null) { CreationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?)); } if(source.TryGetProperty("IsFreeTrial", out token) && token.Type != JTokenType.Null) { IsFreeTrial = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsCancelled", out token) && token.Type != JTokenType.Null) { IsCancelled = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CancellationDate", out token) && token.Type != JTokenType.Null) { CancellationDate = (DateTime?)serializer.Deserialize(token.CreateReader(), typeof(DateTime?)); } if(source.TryGetProperty("SSO", out token) && token.Type != JTokenType.Null) { SSO = (SSOAccountProvider)serializer.Deserialize(token.CreateReader(), typeof(SSOAccountProvider)); } if(source.TryGetProperty("Preferences", out token) && token.Type != JTokenType.Null) { Preferences = (AccountPreferences)serializer.Deserialize(token.CreateReader(), typeof(AccountPreferences)); } if(source.TryGetProperty("ProductDefaults", out token) && token.Type != JTokenType.Null) { ProductDefaults = (ProductDefaults)serializer.Deserialize(token.CreateReader(), typeof(ProductDefaults)); } if(source.TryGetProperty("Subdomain", out token) && token.Type != JTokenType.Null) { Subdomain = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Subdomains", out token) && token.Type != JTokenType.Null) { Subdomains = (IEnumerable<string>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<string>)); } if(source.TryGetProperty("MobileSecuritySettings", out token) && token.Type != JTokenType.Null) { MobileSecuritySettings = (MobileSecuritySettings)serializer.Deserialize(token.CreateReader(), typeof(MobileSecuritySettings)); } if(source.TryGetProperty("LoginAccessControlDomains", out token) && token.Type != JTokenType.Null) { LoginAccessControlDomains = (AccessControlDomains)serializer.Deserialize(token.CreateReader(), typeof(AccessControlDomains)); } if(source.TryGetProperty("FolderAccessControlDomains", out token) && token.Type != JTokenType.Null) { FolderAccessControlDomains = (AccessControlDomains)serializer.Deserialize(token.CreateReader(), typeof(AccessControlDomains)); } if(source.TryGetProperty("StorageQuotaPerUser", out token) && token.Type != JTokenType.Null) { StorageQuotaPerUser = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("FreeTrialId", out token) && token.Type != JTokenType.Null) { FreeTrialId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("Source", out token) && token.Type != JTokenType.Null) { Source = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("AttributedSource", out token) && token.Type != JTokenType.Null) { AttributedSource = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("CompanyURL", out token) && token.Type != JTokenType.Null) { CompanyURL = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("MarketingOptIn", out token) && token.Type != JTokenType.Null) { MarketingOptIn = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CreditCardSecurityCode", out token) && token.Type != JTokenType.Null) { CreditCardSecurityCode = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("ToolInformation", out token) && token.Type != JTokenType.Null) { ToolInformation = (IEnumerable<ToolInformation>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<ToolInformation>)); } if(source.TryGetProperty("BillingInformation", out token) && token.Type != JTokenType.Null) { BillingInformation = (BillingInfo)serializer.Deserialize(token.CreateReader(), typeof(BillingInfo)); } if(source.TryGetProperty("AccountSubType", out token) && token.Type != JTokenType.Null) { AccountSubType = (SafeEnum<AccountSubType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<AccountSubType>)); } } }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as ItemInfo; if(typedSource != null) { CurrentAccessControl = typedSource.CurrentAccessControl; HasVroot = typedSource.HasVroot; IsSystemRoot = typedSource.IsSystemRoot; IsAccountRoot = typedSource.IsAccountRoot; IsVRoot = typedSource.IsVRoot; IsMyFolders = typedSource.IsMyFolders; IsAHomeFolder = typedSource.IsAHomeFolder; IsMyHomeFolder = typedSource.IsMyHomeFolder; IsAStartFolder = typedSource.IsAStartFolder; IsSharedFolder = typedSource.IsSharedFolder; IsPassthrough = typedSource.IsPassthrough; IsVersioned = typedSource.IsVersioned; CanAddFolder = typedSource.CanAddFolder; CanAddNode = typedSource.CanAddNode; CanView = typedSource.CanView; CanDownload = typedSource.CanDownload; CanWatermarkDownload = typedSource.CanWatermarkDownload; CanDocViewerPrint = typedSource.CanDocViewerPrint; CanUpload = typedSource.CanUpload; CanSend = typedSource.CanSend; CanDeleteCurrentItem = typedSource.CanDeleteCurrentItem; CanDeleteChildItems = typedSource.CanDeleteChildItems; CanManagePermissions = typedSource.CanManagePermissions; CanEditFolderOpts = typedSource.CanEditFolderOpts; FolderPayID = typedSource.FolderPayID; ShowFolderPayBuyButton = typedSource.ShowFolderPayBuyButton; TreeMode = typedSource.TreeMode; Versioning = typedSource.Versioning; TreeModeOperationAllowed = typedSource.TreeModeOperationAllowed; TreeModeSourceId = typedSource.TreeModeSourceId; ForcedSortField = typedSource.ForcedSortField; ForcedSortOrder = typedSource.ForcedSortOrder; MaxVersions = typedSource.MaxVersions; DocumentViewerPrinting = typedSource.DocumentViewerPrinting; WatermarkedDownloads = typedSource.WatermarkedDownloads; OptionPropagation = typedSource.OptionPropagation; ViewOnlyWatermarkText = typedSource.ViewOnlyWatermarkText; SortField = typedSource.SortField; SortDirection = typedSource.SortDirection; } else { JToken token; if(source.TryGetProperty("CurrentAccessControl", out token) && token.Type != JTokenType.Null) { CurrentAccessControl = (AccessControl)serializer.Deserialize(token.CreateReader(), typeof(AccessControl)); } if(source.TryGetProperty("HasVroot", out token) && token.Type != JTokenType.Null) { HasVroot = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsSystemRoot", out token) && token.Type != JTokenType.Null) { IsSystemRoot = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsAccountRoot", out token) && token.Type != JTokenType.Null) { IsAccountRoot = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsVRoot", out token) && token.Type != JTokenType.Null) { IsVRoot = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsMyFolders", out token) && token.Type != JTokenType.Null) { IsMyFolders = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsAHomeFolder", out token) && token.Type != JTokenType.Null) { IsAHomeFolder = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsMyHomeFolder", out token) && token.Type != JTokenType.Null) { IsMyHomeFolder = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsAStartFolder", out token) && token.Type != JTokenType.Null) { IsAStartFolder = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsSharedFolder", out token) && token.Type != JTokenType.Null) { IsSharedFolder = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsPassthrough", out token) && token.Type != JTokenType.Null) { IsPassthrough = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("IsVersioned", out token) && token.Type != JTokenType.Null) { IsVersioned = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanAddFolder", out token) && token.Type != JTokenType.Null) { CanAddFolder = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanAddNode", out token) && token.Type != JTokenType.Null) { CanAddNode = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanView", out token) && token.Type != JTokenType.Null) { CanView = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanDownload", out token) && token.Type != JTokenType.Null) { CanDownload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanWatermarkDownload", out token) && token.Type != JTokenType.Null) { CanWatermarkDownload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanDocViewerPrint", out token) && token.Type != JTokenType.Null) { CanDocViewerPrint = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanUpload", out token) && token.Type != JTokenType.Null) { CanUpload = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanSend", out token) && token.Type != JTokenType.Null) { CanSend = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanDeleteCurrentItem", out token) && token.Type != JTokenType.Null) { CanDeleteCurrentItem = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanDeleteChildItems", out token) && token.Type != JTokenType.Null) { CanDeleteChildItems = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanManagePermissions", out token) && token.Type != JTokenType.Null) { CanManagePermissions = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("CanEditFolderOpts", out token) && token.Type != JTokenType.Null) { CanEditFolderOpts = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("FolderPayID", out token) && token.Type != JTokenType.Null) { FolderPayID = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("ShowFolderPayBuyButton", out token) && token.Type != JTokenType.Null) { ShowFolderPayBuyButton = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("TreeMode", out token) && token.Type != JTokenType.Null) { TreeMode = (SafeEnum<TreeMode>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<TreeMode>)); } if(source.TryGetProperty("Versioning", out token) && token.Type != JTokenType.Null) { Versioning = (SafeEnum<Versioning>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<Versioning>)); } if(source.TryGetProperty("TreeModeOperationAllowed", out token) && token.Type != JTokenType.Null) { TreeModeOperationAllowed = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("TreeModeSourceId", out token) && token.Type != JTokenType.Null) { TreeModeSourceId = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("ForcedSortField", out token) && token.Type != JTokenType.Null) { ForcedSortField = (SafeEnum<SortField>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<SortField>)); } if(source.TryGetProperty("ForcedSortOrder", out token) && token.Type != JTokenType.Null) { ForcedSortOrder = (SafeEnum<SortDirection>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<SortDirection>)); } if(source.TryGetProperty("MaxVersions", out token) && token.Type != JTokenType.Null) { MaxVersions = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("DocumentViewerPrinting", out token) && token.Type != JTokenType.Null) { DocumentViewerPrinting = (SafeEnum<DocumentViewerPrinting>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<DocumentViewerPrinting>)); } if(source.TryGetProperty("WatermarkedDownloads", out token) && token.Type != JTokenType.Null) { WatermarkedDownloads = (SafeEnum<WatermarkedDownloads>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<WatermarkedDownloads>)); } if(source.TryGetProperty("OptionPropagation", out token) && token.Type != JTokenType.Null) { OptionPropagation = (IEnumerable<SafeEnum<FolderOption>>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<SafeEnum<FolderOption>>)); } if(source.TryGetProperty("ViewOnlyWatermarkText", out token) && token.Type != JTokenType.Null) { ViewOnlyWatermarkText = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("SortField", out token) && token.Type != JTokenType.Null) { SortField = (SafeEnum<SortField>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<SortField>)); } if(source.TryGetProperty("SortDirection", out token) && token.Type != JTokenType.Null) { SortDirection = (SafeEnum<SortDirection>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<SortDirection>)); } } }
//[ExpectedException(typeof(TypeInitializationException))] public void TestSafeEnum_ConstructionError2() { VoatAssert.Throws <TypeInitializationException>(() => { SafeEnum <int> x = new SafeEnum <int>(45); }); }
public override void Copy(ODataObject source, JsonSerializer serializer) { if(source == null || serializer == null) return; base.Copy(source, serializer); var typedSource = source as Zone; if(typedSource != null) { Secret = typedSource.Secret; ZoneType = typedSource.ZoneType; Account = typedSource.Account; HeartBeatTolerance = typedSource.HeartBeatTolerance; PingBackInterval = typedSource.PingBackInterval; Version = typedSource.Version; ZoneServices = typedSource.ZoneServices; IsHIPAAZone = typedSource.IsHIPAAZone; StorageCenters = typedSource.StorageCenters; Metadata = typedSource.Metadata; } else { JToken token; if(source.TryGetProperty("Secret", out token) && token.Type != JTokenType.Null) { Secret = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("ZoneType", out token) && token.Type != JTokenType.Null) { ZoneType = (SafeEnum<ZoneType>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<ZoneType>)); } if(source.TryGetProperty("Account", out token) && token.Type != JTokenType.Null) { Account = (Account)serializer.Deserialize(token.CreateReader(), typeof(Account)); } if(source.TryGetProperty("HeartBeatTolerance", out token) && token.Type != JTokenType.Null) { HeartBeatTolerance = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("PingBackInterval", out token) && token.Type != JTokenType.Null) { PingBackInterval = (int?)serializer.Deserialize(token.CreateReader(), typeof(int?)); } if(source.TryGetProperty("Version", out token) && token.Type != JTokenType.Null) { Version = (string)serializer.Deserialize(token.CreateReader(), typeof(string)); } if(source.TryGetProperty("ZoneServices", out token) && token.Type != JTokenType.Null) { ZoneServices = (SafeEnum<ZoneService>)serializer.Deserialize(token.CreateReader(), typeof(SafeEnum<ZoneService>)); } if(source.TryGetProperty("IsHIPAAZone", out token) && token.Type != JTokenType.Null) { IsHIPAAZone = (bool?)serializer.Deserialize(token.CreateReader(), typeof(bool?)); } if(source.TryGetProperty("StorageCenters", out token) && token.Type != JTokenType.Null) { StorageCenters = (IEnumerable<StorageCenter>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<StorageCenter>)); } if(source.TryGetProperty("Metadata", out token) && token.Type != JTokenType.Null) { Metadata = (IEnumerable<Metadata>)serializer.Deserialize(token.CreateReader(), typeof(IEnumerable<Metadata>)); } } }