Пример #1
0
        static void Main(string[] args)
        {
            var  aa = db.BBBBs.All();
            BBBB b  = new BBBB {
                Name = "ZXCZXCZXC"
            };                                       //Id = Guid.NewGuid(),

            db.BBBBs.Insert(b);
            var  tt = db.BBBBs.Single(new Guid("140512b2-c499-4602-bccf-50e30260a5b1"));
            AAAA a  = new AAAA {
                BBBB = new Guid("140512b2-c499-4602-bccf-50e30260a5b1"), NameAAA = "AAAA111"
            };

            db.AAAAs.Insert(a);
            var cc      = db.BBBBs.All();
            var dd      = db.AAAAs.All();
            var ttasdas = 1;
            //var ttt = b;
            var sdfsd = 1;
        }
Пример #2
0
        public static void Main(this int target)
        {
            int x = 4;

#if !RANDOM_STUFF
            AAAA.What <int>(1, 2);
            AAAA.What <int>(AAAA.What <int>(1, 2), AAAA.What <int>(3, 4));
#else
            x = 3.DoSomething(5); // shouldnt be transformed
#endif
            x = 3.DoSomething(5);
            var a = x.DoSomethingElse(WOW);
#if RANDOM_YEAH
#else
#endif
#if RANDOM_STUFF
            WOW.DoSomethingElse <double>(a).DoSomething(234).What(56); // shouldnt be transformed
#else
            WOW.DoSomethingElse <double>(a).DoSomething(234).What(56);
#endif
            var b = WOW.DoSomethingElse <double>(a).DoSomething(234).What(56);
        }
 public static void PopulateTestHierarchy(Domain domain)
 {
     using (var session = domain.OpenSession())
         using (var tx = session.OpenTransaction()) {
             for (int i = 0; i < 10; i++)
             {
                 var aaaa = new AAAA {
                     Reference1 = new ReferenceEntity1 {
                         Reference = new ReferenceEntity10(),
                         Address   = new Address {
                             Country  = "Country #1" + i + "00",
                             Region   = "Region #1" + i + "00",
                             City     = "City #1" + i + "00",
                             Street   = "Street #1" + i + "00",
                             Index    = "Index #1" + i + "00",
                             Building = "Building #1" + i + "00",
                         },
                         Passport = new PassportData {
                             Number = "N#1" + i,
                             Series = "S#1" + i
                         }
                     },
                     Reference2 = new ReferenceEntity2 {
                         Reference = new ReferenceEntity10(),
                         Address   = new Address {
                             Country  = "Country #2" + i + "00",
                             Region   = "Region #2" + i + "00",
                             City     = "City #2" + i + "00",
                             Street   = "Street #2" + i + "00",
                             Index    = "Index #2" + i + "00",
                             Building = "Building #2" + i + "00",
                         },
                         Passport = new PassportData {
                             Number = "N#2" + i,
                             Series = "S#2" + i
                         }
                     },
                     Reference3 = new ReferenceEntity3 {
                         Reference = new ReferenceEntity10(),
                         Address   = new Address {
                             Country  = "Country #3" + i + "00",
                             Region   = "Region #3" + i + "00",
                             City     = "City #3" + i + "00",
                             Street   = "Street #3" + i + "00",
                             Index    = "Index #3" + i + "00",
                             Building = "Building #3" + i + "00",
                         },
                         Passport = new PassportData {
                             Number = "N#2" + i,
                             Series = "S#2" + i,
                         }
                     },
                     SomeObject = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())
                 };
                 for (int j = 0; j < 10; j++)
                 {
                     var bbbb = new BBBB {
                         Reference4 = new ReferenceEntity4()
                         {
                             Reference = new ReferenceEntity10(),
                             Address   = new Address {
                                 Country  = "Country #1" + i + j + "00",
                                 Region   = "Region #1" + i + j + "00",
                                 City     = "City #1" + i + j + "00",
                                 Street   = "Street #1" + i + j + "00",
                                 Index    = "Index #1" + i + j + "00",
                                 Building = "Building #4" + i + j + "00",
                             },
                             Passport = new PassportData {
                                 Number = "N#4" + i + j,
                                 Series = "S#4" + i + j
                             }
                         },
                         Reference5 = new ReferenceEntity5()
                         {
                             Reference = new ReferenceEntity10(),
                             Address   = new Address {
                                 Country  = "Country #5" + i + j + "00",
                                 Region   = "Region #5" + i + j + "00",
                                 City     = "City #5" + i + j + "00",
                                 Street   = "Street #5" + i + j + "00",
                                 Index    = "Index #5" + i + j + "00",
                                 Building = "Building #5" + i + j + "00",
                             },
                             Passport = new PassportData {
                                 Number = "N#5" + i + j,
                                 Series = "S#5" + i + j
                             }
                         },
                         Reference6 = new ReferenceEntity6 {
                             Reference = new ReferenceEntity10(),
                             Address   = new Address {
                                 Country  = "Country #6" + i + j + "00",
                                 Region   = "Region #6" + i + j + "00",
                                 City     = "City #6" + i + j + "00",
                                 Street   = "Street #6" + i + j + "00",
                                 Index    = "Index #6" + i + j + "00",
                                 Building = "Building #6" + i + j + "00",
                             },
                             Passport = new PassportData {
                                 Number = "N#6" + i + j,
                                 Series = "S#6" + i + j
                             }
                         },
                         SomeObject = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())
                     };
                     for (int k = 0; k < 10; k++)
                     {
                         var cccc = new CCCC {
                             Reference7 = new ReferenceEntity7 {
                                 Reference = new ReferenceEntity10(),
                                 Address   = new Address {
                                     Country  = "Country #7" + i + j + k + "00",
                                     Region   = "Region #7" + i + j + k + "00",
                                     City     = "City #7" + i + j + k + "00",
                                     Street   = "Street #7" + i + j + k + "00",
                                     Index    = "Index #7" + i + j + k + "00",
                                     Building = "Building #7" + i + j + k + "00",
                                 },
                                 Passport = new PassportData {
                                     Number = "N#7" + i + j + k,
                                     Series = "S#7" + i + j + k
                                 }
                             },
                             Reference8 = new ReferenceEntity8 {
                                 Reference = new ReferenceEntity10(),
                                 Address   = new Address {
                                     Country  = "Country #8" + i + j + k + "00",
                                     Region   = "Region #8" + i + j + k + "00",
                                     City     = "City #8" + i + j + k + "00",
                                     Street   = "Street #8" + i + j + k + "00",
                                     Index    = "Index #8" + i + j + k + "00",
                                     Building = "Building #8" + i + j + k + "00",
                                 },
                                 Passport = new PassportData {
                                     Number = "N#8" + i + j + k,
                                     Series = "S#8" + i + j + k
                                 }
                             },
                             Reference9 = new ReferenceEntity9 {
                                 Reference = new ReferenceEntity10(),
                                 Address   = new Address {
                                     Country  = "Country #9" + i + j + k + "00",
                                     Region   = "Region #9" + i + j + k + "00",
                                     City     = "City #9" + i + j + k + "00",
                                     Street   = "Street #9" + i + j + k + "00",
                                     Index    = "Index #9" + i + j + k + "00",
                                     Building = "Building #9" + i + j + k + "00",
                                 },
                                 Passport = new PassportData {
                                     Number = "N#9" + i + j + k,
                                     Series = "S#9" + i + j + k
                                 }
                             },
                             SomeObject = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())
                         };
                         bbbb.CCCCs.Add(cccc);
                     }
                     aaaa.Bbbbs.Add(bbbb);
                 }
             }
             tx.Complete();
         }
 }
Пример #4
0
        protected override void ProcessRecord()
        {
            this.SetOptions();
            this.SetScope(Server);
            this.SetManagementPath(Identity);
            ManagementObject wmiRecord = this.Get();

            WmiRecordClass WmiRecordClassName = (WmiRecordClass)Enum.Parse(typeof(WmiRecordClass), (String)wmiRecord.Properties["__CLASS"].Value);
            String         NewPath            = String.Empty;

            #region Parameter Set validation
            Boolean Terminate = false;
            switch (ParameterSetName)
            {
            case "PS0": break;

            case "PS1":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AAAAType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WKSType)
                {
                    Terminate = true;
                }
                break;

            case "PS2":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_CNAMEType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MBType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MDType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MFType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_NSType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_PTRType)
                {
                    Terminate = true;
                }
                break;

            case "PS3":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MGType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MRType)
                {
                    Terminate = true;
                }
                break;

            case "PS4":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_TXTType)
                {
                    Terminate = true;
                }
                break;

            case "PS5":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_HINFOType)
                {
                    Terminate = true;
                }
                break;

            case "PS6":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_ISDNType)
                {
                    Terminate = true;
                }
                break;

            case "PS7":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MINFOType)
                {
                    Terminate = true;
                }
                break;

            case "PS8":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_NXTType)
                {
                    Terminate = true;
                }
                break;

            case "PS9":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_RPType)
                {
                    Terminate = true;
                }
                break;

            case "PS10":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AFSDBType)
                {
                    Terminate = true;
                }
                break;

            case "PS11":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MXType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_RTType)
                {
                    Terminate = true;
                }
                break;

            case "PS12":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_X25Type)
                {
                    Terminate = true;
                }
                break;

            case "PS13":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_SOAType)
                {
                    Terminate = true;
                }
                break;

            case "PS14":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_SRVType)
                {
                    Terminate = true;
                }
                break;

            case "PS15":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WINSType)
                {
                    Terminate = true;
                }
                break;

            case "PS16":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WINSRType)
                {
                    Terminate = true;
                }
                break;
            }

            if (Terminate)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        new PSInvalidOperationException("InvalidParameterSetForRecordType"),
                        "InvalidOperation",
                        ErrorCategory.InvalidOperation,
                        typeof(ManagementCmdlet)));
            }
            #endregion

            if (ShouldProcess((String)wmiRecord.Properties["TextRepresentation"].Value))
            {
                switch (WmiRecordClassName)
                {
                case WmiRecordClass.MicrosoftDNS_AType:
                    A ARecord = new A(wmiRecord, Server);
                    NewPath = ARecord.Modify(TTL, Address.ToString());
                    break;

                case WmiRecordClass.MicrosoftDNS_AAAAType:
                    AAAA AAAARecord = new AAAA(wmiRecord, Server);
                    NewPath = AAAARecord.Modify(TTL, Address.ToString());
                    break;

                case WmiRecordClass.MicrosoftDNS_AFSDBType:
                    AFSDB AFSDBRecord = new AFSDB(wmiRecord, Server);
                    NewPath = AFSDBRecord.Modify(TTL, SubType, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_CNAMEType:
                    CNAME CNAMERecord = new CNAME(wmiRecord, Server);
                    NewPath = CNAMERecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_HINFOType:
                    HINFO HINFORecord = new HINFO(wmiRecord, Server);
                    NewPath = HINFORecord.Modify(TTL, CPU, OS);
                    break;

                case WmiRecordClass.MicrosoftDNS_ISDNType:
                    ISDN ISDNRecord = new ISDN(wmiRecord, Server);
                    NewPath = ISDNRecord.Modify(TTL, ISDNNumber, SubAddress);
                    break;

                case WmiRecordClass.MicrosoftDNS_MBType:
                    MB MBRecord = new MB(wmiRecord, Server);
                    NewPath = MBRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MDType:
                    MD MDRecord = new MD(wmiRecord, Server);
                    NewPath = MDRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MFType:
                    MF MFRecord = new MF(wmiRecord, Server);
                    NewPath = MFRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MGType:
                    MG MGRecord = new MG(wmiRecord, Server);
                    NewPath = MGRecord.Modify(TTL, MailboxName);
                    break;

                case WmiRecordClass.MicrosoftDNS_MINFOType:
                    MINFO MINFORecord = new MINFO(wmiRecord, Server);
                    NewPath = MINFORecord.Modify(TTL, ResponsibleMailbox, ErrorMailbox);
                    break;

                case WmiRecordClass.MicrosoftDNS_MRType:
                    MR MRRecord = new MR(wmiRecord, Server);
                    NewPath = MRRecord.Modify(TTL, MailboxName);
                    break;

                case WmiRecordClass.MicrosoftDNS_MXType:
                    MX MXRecord = new MX(wmiRecord, Server);
                    NewPath = MXRecord.Modify(TTL, Preference, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_NSType:
                    NS NSRecord = new NS(wmiRecord, Server);
                    NewPath = NSRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_NXTType:
                    NXT NXTRecord = new NXT(wmiRecord, Server);
                    NewPath = NXTRecord.Modify(TTL, NextDomainName, Types);
                    break;

                case WmiRecordClass.MicrosoftDNS_PTRType:
                    PTR PTRRecord = new PTR(wmiRecord, Server);
                    NewPath = PTRRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_RPType:
                    RP RPRecord = new RP(wmiRecord, Server);
                    NewPath = RPRecord.Modify(TTL, ResponsibleMailbox, TXTDomainName);
                    break;

                case WmiRecordClass.MicrosoftDNS_RTType:
                    RT RTRecord = new RT(wmiRecord, Server);
                    NewPath = RTRecord.Modify(TTL, Preference, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_SOAType:
                    SOA SOARecord = new SOA(wmiRecord, Server);
                    NewPath = SOARecord.Modify(TTL, SerialNumber,
                                               SOAServer, ResponsibleMailbox, RefreshInterval,
                                               RetryDelay, ExpireLimit, MinimumTTL);
                    break;

                case WmiRecordClass.MicrosoftDNS_SRVType:
                    SRV SRVRecord = new SRV(wmiRecord, Server);
                    NewPath = SRVRecord.Modify(TTL, Priority, Weight, Port, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_TXTType:
                    TXT TXTRecord = new TXT(wmiRecord, Server);
                    NewPath = TXTRecord.Modify(TTL, Text);
                    break;

                case WmiRecordClass.MicrosoftDNS_WINSType:
                    WINS WINSRecord = new WINS(wmiRecord, Server);
                    NewPath = WINSRecord.Modify(TTL, MappingFlag, LookupTimeout,
                                                CacheTimeout, String.Join(" ", WinsServers));
                    break;

                case WmiRecordClass.MicrosoftDNS_WINSRType:
                    WINSR WINSRRecord = new WINSR(wmiRecord, Server);
                    NewPath = WINSRRecord.Modify(TTL, MappingFlag, LookupTimeout,
                                                 CacheTimeout, ResultDomain);
                    break;

                case WmiRecordClass.MicrosoftDNS_WKSType:
                    WKS WKSRecord = new WKS(wmiRecord, Server);
                    NewPath = WKSRecord.Modify(Address, TTL, IPProtocol, String.Join(" ", Services));
                    break;

                case WmiRecordClass.MicrosoftDNS_X25Type:
                    X25 X25Record = new X25(wmiRecord, Server);
                    NewPath = X25Record.Modify(TTL, PSDNAddress);
                    break;

                default:
                    ThrowTerminatingError(
                        new ErrorRecord(
                            new PSNotSupportedException("Unsupported Record Type"),
                            "RecordModificationNotSupported",
                            ErrorCategory.NotImplemented,
                            typeof(ManagementCmdlet)));
                    break;
                }

                if (PassThru)
                {
                    this.SetManagementPath(NewPath);
                    wmiRecord = this.Get();

                    WriteRecord(wmiRecord);
                }
            }
        }